This one has got me.
This works:
print "Processing Feed\n";
while ( my @p = $mainex->fetchrow_array ) {
my $iis = "$pcount";
print "$iis\n";
# ... Do Other Stuff Here
$pcount++;
}
Which gives:
Processing Feed
1
2
3
4
5
6
7
8
9
10
...
This does not work (removed the \n from line 4):
print "Processing Feed\n";
while ( my @p = $mainex->fetchrow_array ) {
my $iis = "$pcount";
print "$iis";
# ... Do Other Stuff Here
$pcount++;
}
Which simply gives:
Processing Feed
I was trying to build a counter that would output the count of the record it was up to using something like:
while( Something ){
print "\b\b\b\b\b\b\b\b\b\b\b";
print "$count";
$count++;
# Do stuff here
}
Any ideas why when there is no \n in the second example nothing is printing to screen? I have done it many times before and cannot figure out why it is not working.
The newline at the end of the print triggers a flush of stdout, which prints to the screen. If you add $|++ to the top of your perl script, it will turn on autoflushing for stdout and you will see your numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With