in reply to editing a file with regular expressions

All you have done is edit a copy of the line in memory, not the file itself. You would need to write the modified output to new file, close it, delete the original and then rename the new file back to the original name.

For a simple mechanism for 'inplace editing' and a piece of example code see perlrun and the description on the -i[ext] switch.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Timing (and a little luck) are everything!