in reply to Empty File Contnts before writing
Yes, closing the filehandle and re-opening for writing with ">" will truncate the file. See open and perlopentut.
Note that you should test open’s return value. Either
use autodie;
or write
open(my $file1, ">", "testing1.txt") or die "Cannot open file 'testing +1.txt' for writing: $!";
Also note that a lexical variable (as shown) is preferable to a bareword for the filehandle.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|