sub back_up_file { my ($index, $index_backup) = @_; # open the necessary files needed for reading and writing open (INDEX, "<$index") or die &show_error ("Unable to open $index: $!"); open(BACKUP, ">$index_backup") or die &show_error ("Unable to open $index_backup: $!"); # write the existing file into the backup while () { print BACKUP "$_"; } # close the files close (INDEX); close (BACKUP); } # shows the error returned inside of the browser - easier debuging sub show_error { print "Content-type: text/html\n\n"; print "This is the error:

$_[0]

"; exit(0); }