in reply to modifying a matched line in a flatfile
You might want to take a look at Tie::File. And at the FAQ - your question is found there too.
Abigail