### Back up the file, if it exists use File::Copy; if(-e $file{1}) # if the file exists { unless(copy($file{1}, $file{2})) { print "Failed to copy file: $!"; exit; # unless you want to do the copy anyway } } ### Copy the database #### 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; }