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; } }