in reply to How to replace text in external file
And something like Tie::File to make the file reading / rewriting nice and simple.