Sep 11, 2012, 6:44 AM
1) Instead of shelling out to the date command, it would be better to use the strftime function from the POSIX module.
Re: [ianilkumar] copy a file with a different name.
2) $PIN_HOME was never assigned a value.
3) You should always use the strict and warnings pragmas. They would have told to about the problem with $PIN_HOME.
4) You should verify that the copy completed successfully and output a proper error message if it didn't.
use POSIX qw(strftime);
my $ext = strftime("Y%m%d%H%M%S", localtime);
my $pin_home = '/home/user';
my $src_file = "$pin_home/sys/data/pricing/example/pin_usage_map";
my $new_file = "$pin_home/sys/data/pricing/example/pin_usage_map.$ext";
copy($src_file, $new_file) or die ("failed to copy '$src_file' to '$new_file' <$!>");
(This post was edited by FishMonger on Sep 11, 2012, 6:45 AM)