in reply to search-and-replace in files
You are changing the file only in memory :-)
Write all the lines including changed ones into a variable, and then when you're done with reading the file, open it again for writing. Then write the content of your variable into it.
--
tune
In Section
Seekers of Perl Wisdom