in reply to Opening, and editing multiple files?

perl -i.bak -pe's/old text/new text/g' directory/*.ext

Or if you want to do that inside your Perl program:

@ARGV == 2 or die "usage: $0 directory extention\n"; my ( $dir, $ext ) = splice @ARGV; ( $^I, @ARGV ) = ( '.bak', <$dir*.$ext> ); while ( <> ) { s/old text/new text/g; print; }