Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

OUTPUT_AUTOFLUSH

by Rabotnik (Initiate)
on Jun 06, 2002 at 14:16 UTC ( [id://172208]=perlquestion: print w/replies, xml ) Need Help??

Rabotnik has asked for the wisdom of the Perl Monks concerning the following question:

Howdy folks! I read that if u set OUTPUT_AUTOFLUSH to non zero, then auto(buffer)flushing is applied for the "currently selected channel". What is the currently selected channel? The last HANDLE used in print? e.g.
print "asd"; $OUTPUT_AUTOFLUSH=1; #this sets the flushing
Does this cause autoflushing for STDOUT? Until what (i guess until another HANDLE is used, e.g.: print STDERR "asd";)?

Replies are listed 'Best First'.
Re: OUTPUT_AUTOFLUSH
by Juerd (Abbot) on Jun 06, 2002 at 14:20 UTC

    It works on the currently selected handle. By the way, you have to use English to use $OUTPUT_AUTOFLUSH. It's easier to use $| (perlvar) instead.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Re: OUTPUT_AUTOFLUSH
by Beatnik (Parson) on Jun 06, 2002 at 14:19 UTC
    You do need English for it, IIRC...
    It works until you unset that filehandle. You can select another filehandle too ofcourse :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: OUTPUT_AUTOFLUSH
by Aristotle (Chancellor) on Jun 06, 2002 at 14:51 UTC
    By default it works on STDOUT. (As has been said, select() another filehandle to change the autoflushing on it.) Note that unlike your example, you should use it prior to performing any operations on that filehandle:
    $|++; print "asd";
    As, again, has been said, the variable is really called $|, and the long name is only available if you use English;. You can also use IO::Handle; and then say STDOUT->autoflush(1);.

    Makeshifts last the longest.

Re: OUTPUT_AUTOFLUSH
by Rabotnik (Initiate) on Jun 11, 2002 at 12:43 UTC
    Hi! I fixed my problem... I put $|++ right @ the start of the script. At first i tried using the same cmd, but somewhere deep in the script (before the 1st print). 10x

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://172208]
Approved by Rex(Wrecks)
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 19:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found