Since this is the third time in the last year I've had to look this up, I am making a note on my blog, where it should be easy for me to find :)
From this 'notes on Perl' page, how to inplace edit a file with perl:
perl -p -i.bak -e "s#a#b#" filename
| Flag | Meaning | |
|---|---|---|
| -p | Execute the command(s) for every line. | |
| -i.bak | Edit the given file in-place ".bak" is the extension name of the backup file. | |
| -e | Introduces the command to execute. The command in this case is 's' for substitute. |
See also perldoc.com for information on regular expression syntax and such.