in reply to file updating question

That's not what you want to do. If you write over the file with something smaller, you will still have old stuff left over at the end. What you should do is write to a NEW file and then move the new file over the old file. You can use "perl -i". See "perldoc perlrun" for details.

Replies are listed 'Best First'.
Re: Re: file updating question
by smackdab (Pilgrim) on Nov 28, 2002 at 03:03 UTC
    Thanks for the pointer, didn't know this stuff. Assuming it is OK to grow the file, how about this??? (It works for my testing...)
    if (open(FILE, "+< stuff.txt")) { local $/ = undef; my $buff = <FILE>; truncate(FILE, 0); # Update $buff print FILE $buff;