in reply to Renaming file with date

You are opening two files using the same file handle; so, the second open() closes previously open file. In addition, you are wiping out the contents of file referenced by $destination.

Don't write your own code for copying files unless you have to.
Use File::Copy instead. strftime() from POSIX will help you format date strings.
use strict; use File::Copy; use POSIX; my @files = ('system.csv', 'sales.csv'); # your files my $home = 'd:/EOD/20 January 2002/'; # source my $archive = 'c:/New EOD/'; # destination # the day before my $yesterday = strftime("%Y%m%d", localtime(time - 24*60*60)); # copy all files from $home to $archive; # prepend yesterday's date to all file names. for (@files){ copy $home.$_, "$archive${yesterday}_$_" or print "ERROR: Can't copy $_ : $!\n"; }
--perlplexer