use strict; my $file = '/tmp/this_file'; my $fh; unless (open($fh,">$file")) { die "I can't open $file for writing: $!"; } truncate $fh, 0; close($fh); #### truncate $myfile, 0;