I
it_says_BALLS_on_your forehead
I've recently come across a problem where I am parsing some large logs,
and end up filling up a file system. The process proceeds however,
since I don't check if the print succeeded or not. I created a simple
script to check print. The last two lines were executed if I didn't
have the 'or die...' clause in the for loop, and they were not if i
did:
use strict; use warnings;
my $time_start = localtime();
my $file = "big_file.txt";
open my $fh_out, '>', $file or die "can't open $file: $!\n";
for my $i ( 0 .. 1_000_000 ) {
print $fh_out 'A' x 100, "\n" or die "couldn't print: $!\n";
}
close $fh_out;
my $time_end = localtime();
print "$0: DONE.\n";
print "START: $time_start\n END: $time_end\n";
and end up filling up a file system. The process proceeds however,
since I don't check if the print succeeded or not. I created a simple
script to check print. The last two lines were executed if I didn't
have the 'or die...' clause in the for loop, and they were not if i
did:
use strict; use warnings;
my $time_start = localtime();
my $file = "big_file.txt";
open my $fh_out, '>', $file or die "can't open $file: $!\n";
for my $i ( 0 .. 1_000_000 ) {
print $fh_out 'A' x 100, "\n" or die "couldn't print: $!\n";
}
close $fh_out;
my $time_end = localtime();
print "$0: DONE.\n";
print "START: $time_start\n END: $time_end\n";