use strict; use warnings; $|++; # make buffer 1 (error happens with or without this) open LOG,">foo.log" or die "can't open foo.log: $!"; while (1) { print LOG (localtime).": something\n"; sleep(30); # if I comment this, print works } #### use strict; use warnings; $|++; # make buffer 1 (error happens with or without this) open LOG,">foo.log" or die "can't open foo.log: $!"; for (my $t=0;$t<3;$t++) { print LOG (localtime).": something\n"; sleep(30); } close LOG or die "can't close log: $!";