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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Empty File Contents before writing
by RichardK (Parson) on Feb 19, 2013 at 11:41 UTC | |
by johngg (Canon) on Feb 19, 2013 at 14:37 UTC |