I think it means that the buffer, when directed to a teminal, is flushed out each newline. As opposed behaviour when the output go to a pipe or to a file that buffer is write to his destination only when it fulls his 4096 (or another fixed size) limit, regardless of newlines.
In fact you can see as the following code does not having newline nor filling the buffer limit, prints its dots all togheter at the end of execution, when the buffer is printed anyway:
perl -e "for (1..10){print qq(.);sleep 1}"
By other hand if you add a newline to the dot, the program prints a dot a second:
perl -e "for (1..10){print qq(.\n);sleep 1}"
You can also force Perl to print out his buffer as soon as possible setting the
$| $OUTPUT_AUTOFLUSH ( see
perlvar) to something true:
perl -e "$|++;for (1..10){print qq(.);sleep 1}"
When the output is directed to a pipe or to a file, the normal expected behaviour is to print when the buffer is full, in this way optimizing a lot the overall execution. Also in this situation you can profit of
$| to flush buffer as soon as possible. You can test this behaviour writing to a tempfile and using tail on that file in another shell window.
As classic read i can address you to
Suffering from buffering?HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.