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:

select(STDERR); print $|;
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")

In reply to (tye)Re: print sleep print by tye
in thread print sleep print by Anonymous Monk

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.