But if Perl is oblivious to whats happening to STDOUT I'll devise another workaround

Perl is not oblivious to this, you would notice the difference when you note these characteristics:

  1. When STDOUT is attached to the terminal it'd have a line-buffered-mechanism, so such a filehandle would be flushed automatically when printing a newline character to it, or whenever you read from the terminal.
  2. When STDOUT is attached to an output file this flushing doesn't take place the same way above, and the program would not write to a file until after it's run throughout or after the buffer has been filled and needed purging (flushing).
  3. STDERR is always in line-buffered mode.

I found this useful link just today, I learnt a lot from it, take a look at it :).


Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: Test if STDOUT is attached to console or shell redirected filehandle by biohisham
in thread Test if STDOUT is attached to console or shell redirected filehandle by desemondo

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.