Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: flushing by default

by kirillm (Friar)
on Jan 19, 2008 at 17:48 UTC ( #663227=note: print w/replies, xml ) Need Help??


in reply to flushing by default

I am interested in how I can make autoflush a default behaviour for all of the filehandles I open

Put this somewhere at the beginning of your program:

$|++;

Setting $| to a non-zero value forces a flush right away and after every write or print on the currently selected output channel. IO::Handle makes use of $| as well.

-- Kirill

Replies are listed 'Best First'.
Re^2: flushing by default
by hungry_john (Acolyte) on Jan 19, 2008 at 18:28 UTC
    Setting $| to a non zero value will force a fflush()
    to be called on the currently selected output channel.

    Use setbuf to remove the buffer on a single file descriptor.
Re^2: flushing by default
by spx2 (Deacon) on Jan 19, 2008 at 17:54 UTC
    yes,but won't this apply just to the handle STDOUT ? will it apply to all handles ?

      Not necessarily on STDOUT, but on the filehandle that is currently selected.

      As for the global default autoflush - I'm not aware of a way to do it. Buffering is usually the default behaviour for the reasons of efficiency.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2022-08-15 00:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?