in reply to Re^3: Empty File Contents before writing
in thread Empty File Contnts before writing
There is also a built-in function called truncate that will do what you want.
$ perl -Mstrict -Mwarnings -e ' > open my $fh, q{>}, q{rubbish} or die $!; > print $fh qq{A longish line of text\n}; > truncate $fh, 0 or die $!; > print $fh qq{Short\n}; > close $fh or die $!;' $ cat rubbish Short $
Update: Added example code.
Cheers,
JohnGG
In Section
Seekers of Perl Wisdom