my $output_file = 'hoser.txt'; # using three argument form and die if there's an error open my $fh, '>', $output_file or die "$output_file: open(w) failed: $!"; my @file_info = stat $fh; or die "$output_file: stat failed: $!"; close $fh or die "$output_file: close(w) failed: $!";