Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
use strict;
use File::Copy;
foreach my $file (map { glob ($_) } @ARGV)
# get a filename for the backup file
my $backup = $file . ".bak";
$backup = $` . ".bak" if ($file =~ /\.\w+$/);
# copy the file to the backup
copy ($file, $backup) or die "Can't copy $file to $backup: $!\n";
# open them both, reading from BACKUP and writing to FILE
open (BACKUP, "<", $backup) or die "Can't open $backup: $!\n";
open (FILE, ">", $file) or die "Can't open $file: $!\n";
# loop on backup and process each line
while (<BACKUP>)
# insert your s/// code here!!
print FILE $_;
close FILE;
close BACKUP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment