Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: The print is output later after die

by syphilis (Archbishop)
on Jan 28, 2022 at 11:51 UTC ( #11140919=note: print w/replies, xml ) Need Help??


in reply to Re: The print is output later after die
in thread The print is output later after die

*STDOUT->autoflush;

My goto answer would have been $|++.
I'm thinking it's a case of "six of one; half-a-dozen of the other".
Is there a difference ?

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: The print is output later after die
by ikegami (Patriarch) on Jan 28, 2022 at 12:21 UTC

    $| = 1; affects the currently selected handle. This is the handle print, printf and say use if you don't provide one., and it defaults to STDOUT.

    In fact, ->autoflush changes the currently selected handle to the invocant, sets $|, then restores the originally selected handle.

Re^3: The print is output later after die
by Discipulus (Canon) on Jan 28, 2022 at 12:05 UTC
    Hello syphilis,

    differences? perlvar says that $|++ flush right away and after every write or print on the currently selected output channel while *STDOUT->autoflush only affect STDOUT your example instead any select -ed FH and so also STDERR in case of warn or die

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re^3: The print is output later after die
by choroba (Cardinal) on Jan 28, 2022 at 12:05 UTC
    See IO::Handle. There's no difference, just readability :-)

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

      There's a difference. $| = 1; is equivalent to select()->autoflush(), not STDOUT->autoflush().

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140919]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2023-03-22 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?