in reply to Editing Files In Place

Editing files inplace is tricky. One has to remember than on most platforms, including UNIX and Windows, files are just sequences of bytes. There is no line based datastructure. Your approach isn't going to work, unless the replacement part is the same length (in bytes) as what you are replacing. But then you are still missing a seek (you need to seek back to reposition the file pointer) and a print.

There are two often used approaches for generic modifications:

You may want to use Tie::File, or investigate the -i option of perl itself (or its $^I equivalent).

Abigail