Hi All,
Why I dont get a's printed with the code below?
+++++++++++++++++++++++++++++++ while(1) { print "a"; sleep 1; } +++++++++++++++++++++++++++++++ It works well if I print a newline with a, i.e while(1) { print "a\n"; # newline with a sleep 1; }
Please help if you know the cause.
TIA Tapas
I think the "problem" is output buffering.
The buffer doesn't get flushed (i.e. its content printed to screen) until it's full.
I guess the newline character causes the buffer to be flushed.
To force buffer flushing after each print, you can se $| to a non-zero value.
I attached a sample script to show this.
Marcello
use strict; use warnings;
$|++; while(1) { print "a"; # with this line we don't get any output unless we put a $|++ beforehand #print "a\n"; # with this line every "a" gets printed regardless of $| value (0 or 1) sleep 1; }
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>