in reply to Substitution in a file

The code is probably working just fine. What you are doing is reading FROM a file, and changing the variable that it is read into ($_). What you are not doing is changing the file.

See the FAQ at How do I change one line in a file/delete a line in a file/insert a line in the middle of a file/append to the beginning of a file? for a good analysis.