The $| = 1; line tells Perl to shut off its buffering;
A bit of a nit, but Perl isn't doing the buffering and setting $|=1 doesn't turn off any buffering. C's stdio library is doing the buffering and $|=1 tells Perl to issue an fflush() after each statement that writes to that file handle (the output handle that was selected when $| was modified).
Some consequences of this are that STDERR is (at least usually) not buffered even though:
prints "0" by default. Also, STDOUT is usually "line buffered" when going to an interactive terminal (the buffer gets flushed by the C RTL whenever a newline is found) but is usually "block buffered" (a fixed-length buffer is used and data is only flushed to the file when that buffer fills) when redirected to a file. - tye (but my friends call me "Tye")select(STDERR); print $|;
In reply to (tye)Re: print sleep print
by tye
in thread print sleep print
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |