My pattern for "search and replace many files" is to first grab the filenames, usually with
File::Find, and then use "inplace editing mode" to do the reading and writing while I concentrate on the editing part.
use File::Find;
{
my @starters = @ARGV ? @ARGV : qw(/home/merlyn);
@ARGV = ();
find sub {
push @ARGV, $File::Find::name if /\.asp$/; # or whatever condition
+ here
}, @starters;
}
{
local $/; # slurp it
local $^I = ".bak";
while (<>) {
# $_ now contains the entire file, alter at will
s/foo/bar/g;
print;
}
}
-- Randal L. Schwartz, Perl hacker