Skip to content

Instantly share code, notes, and snippets.

@davorg
Created November 29, 2012 09:58
Show Gist options
  • Save davorg/4167915 to your computer and use it in GitHub Desktop.
Save davorg/4167915 to your computer and use it in GitHub Desktop.
Copy file contents to new file named using timestamp
#!/usr/bin/perl
use strict;
use warnings;
use Time::Piece;
my $src_file = 'ABC.txt';
my $t = localtime;
open my $in_fh, '<', $src_file
or die "Can't open $src_file for reading: $!\n";
open my $out_fh, '>', 'ABC-' . $t->strftime('%m.%d.%Y-%T') . '.txt';
print $out_fh $_ while <$in_fh>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment