if(-e $file{1}) # if the file exists { open FILE1, "< $file{1} or die "Failed to open $file{1}". " for reading: $!"; local $/ = ""; # prepare to read the whole # file in at once my $filecontents = ; close FILE1; open FILE2, "> $file{2} or die "Failed to open $file{2}". " for writing: $!"; print FILE2 $filecontents; close FILE2; }