gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
(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:
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!sub PRINT { ... my $sel = select("FOOBAR::STDOUT") ; my $autoflush_val = $| ; select($sel) ; ... }
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".
|
|---|