in reply to Regex stored in a scalar
If the only thing you're doing inside the loop is one or two regex substitutions, and the way you describe it, the scripts sound like they're throwaways, you may want to look at the -e, -p and maybe also -i switches in perlrun, i.e. write one-liners:
$ cat foo.txt one two three $ perl -wMstrict -pe 's/^t(?!h)/th/; s/(.)\1/$1/g' foo.txt > bar.txt $ cat bar.txt one thwo thre $ perl -wMstrict -pe 's/th/ph/g' -i.bak bar.txt $ cat bar.txt one phwo phre $ cat bar.txt.bak one thwo thre
|
|---|