Hi,
0 means both STDERR and STDOUT were buffered
No, that's not correct, it simply reflects the state of the "autoflush" setting. From $|:
Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after each write).
ie the default is they are buffered
The issue here is not whether they are buffered, as they always are in one form or another, but the issue is when that buffer is flushed. According to Suffering from Buffering:
When a filehandle is attached to the terminal, ... it is in line buffered mode by default. A filehandle in line buffered mode has two special properties: It's flushed automatically whenever you print a newline character to it, and it's flushed automatically whenever you read from the terminal. ... But now let's try it with STDOUT attached to a file instead of to the terminal... it isn't line-buffered; only filehandles attached to the terminal are line-buffered by default. ... The filehandle STDERR, which is normally used for error logging, is always in line buffered mode by default.
And the autoflush setting
forces a flush right away and after every write or print on the currently selected output channel.
So STDERR is always in line-buffered mode by default, and Perl decides whether STDOUT should be line-buffered or not depending on whether it's attached to a terminal or not.
Regards,
-- Hauke D
In reply to Re^6: Need sleep walking help
by haukex
in thread Need sleep walking help
by Todd Chester
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |