I made an STDOUT redirection that handles automatically the heanders output. Soo I was testing all the possible behaviors and found a bug with $|.

(Just to remember, $| is the autoflush value of the selected output.)

The problem is that you can print to the HANDLER without select() it, soo the $| that PRINT() inside the TIEHANDLE class reads, isn't the autoflush value ($|) of it self, is the value of another selected output.

Soo, I need to get explicity the autoflush value ($|) of the tied handler. For that I was thinking to set the selected output to the TIEDHANDLE when inside the PRINT, and when going out of it reset to the previouse output, with something like that:

sub PRINT { ... my $sel = select("FOOBAR::STDOUT") ; my $autoflush_val = $| ; select($sel) ; ... }
But this is a big problem, since I can't know where the GLOB of my tied HANDLER lives (in the code FOOBAR::STDOUT), and even if I know I can't change the selected output when inside of PRINT, since I can't ensure that I really can reselect the previouse output ($sel), since some output aren't global or can be another tied handler. Soo, this approach will bring much more bugs!

Soo, there is a way to get the autoflush value of a tied handler without use $| ?
(Let's try to avoid XS hack, but any XS code is still welcome).

Update: Just to be explicity, I'm not talking about buffers! I'm just talking in a way to get the $| value, and ensure that this value is from my tied handle! What I will do with it (buffer system or not) is my bussiness.

Graciliano M. P.
"Creativity is the expression of the liberty".


In reply to How to get explicity the autoflush var ($|) of a TIED HANDLER? by gmpassos

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.