DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Perl Inline File Edit Straight From Perl FAQ
// description of your code here
#!/usr/bin/perl
use strict;
use warnings;
my $filename = 'some_file.txt';
my $find = 'this';
my $replace = 'that';
{
local @ARGV = ($filename);
local $^I = '.bac';#<-- invokes inplace editing
while( <> ){
if( s/$find/$replace/ig ) {
print;
}
else {
print;
}
}
}





