Created
June 20, 2009 01:56
-
-
Save LastOfTheCarelessMen/132998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!! | |
s/this/that/g; | |
print FILE $_; | |
} | |
close FILE; | |
close BACKUP; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment