The script I am working on was perfectly functonal 2 hours ago, printing results to a file.
After miner changes, including addition of a loop, the script stopped printing to file.
Env: Windows 10 command line; perl version v5.32.1.
Some code:
if($resultFile ne ''){
print "Opening $resultFile for outputn";
open(OUT,">$resultFile") || die "Could not open output file, $resultFile;$!n";
print OUT "test 0n";
}
# test code
my $list = 'foo';
my $newline = "barn";
open FH, '>', "$list.tmp" or die "$list == $!";
print FH $newline or die "Error print: $!";
#close FH;
print $newline;
## begin CASES loop
my $i=0;
while(<CASES>) {
my $case = $_;
chomp($case);
print "$casen";
print OUT "$casen";
my @data1;
[snip : a lot of processing]
print "@data1n";
print OUT "@data1n";
print FH "test 6n";
## end of CASES loop
}
Output: (after printing for a short time)
type test_results3.txt
”
type foo.tmp
”
If I let the script run longer, output will show up in test_results3.txt, but not foo.tmp.
I have “$| = 1” set in the top of the script.
So my question is: why is data not being dumped immediately after each print statement–as it is supposed to do for $|=1 ?
Is there some minimum amount of buffering going on? The $|=1 is supposed to turn off output buffering.
What’s going on here?
Thanks for any insight you might have on this .
Joe White