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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.