in reply to text manipulation

I have a great book for you that has the answer to this one. Its called the Perl Cookbook. Its worth its weight in gold for stuff like this.

One of the examples in Chapter 7 should do it for you.
7.10 Modifying a file in place without a temporary file

open(FH, "+< FILE") or die "Can't open file: $!"; @file_array = <FH>; # perverse, abuse, and do stuff to array here seek(FH, 0, 0); print FH @file_array; truncate(FH,tell(FH)); close(FH);

Just throwing out a suggestion. There are a dozen or so ways to do this.

Good luck,
BMaximus