http://qs321.pair.com?node_id=100568


in reply to Can you teach a new dog an old trick?

It's such a common idiom that the -p and -i command-line flags were invented to deal with it:

#!/usr/bin/perl -wpi s/string1/string2/g;

And then you'd run it as: myScript *.htm

update: note that the contents of a script run with -p or -n are inside a loop. If you want to initialize anything before the loop, use a BEGIN or INIT block.