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

Re: Flushing the print buffers.

by FunkyMonk (Canon)
on Feb 21, 2008 at 19:58 UTC ( #669375=note: print w/replies, xml ) Need Help??

in reply to Flushing the print buffers.

I guess you got a "Name "main::OUTPUT_HANDLE" used only once: possible typo" warning with the code you posted


my $old_fh = select(STDOUT); $| = 1; select($old_fh);

  • The first select changes the default output filehandle to STDOUT and returns the current default output filehandle to be saved in $old_fh.
  • $|=1 turns on autoflushing on the current output filehandle
  • select($old_fh) restores the original output filehandle

Generally, if you just want to turn on autoflushing on STDOUT, a simple $|=1 will do.

Replies are listed 'Best First'.
Re^2: Flushing the print buffers.
by kansaschuck (Sexton) on Feb 23, 2008 at 06:01 UTC
    This worked nicely:
    my $old_fh = select(STDOUT); $| = 1; select($old_fh);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://669375]
[james28909]: i cannot understand how someone cant see that a cloud of gas that evolves into a solar system or galaxies. it just makes sense to me. everythign that has happened, had to have happened for anything on this planet to be.
[james28909]: /gas/gas and debris/
[james28909]: another thing, i used to be atheist. life experiences, personal evidence. and my own perception is the reason why i believe the things i do.
[erix]: and now you are agnostic?
[james28909]: arunbear, your picking bits of history to fit your own narrative. right now, humans are smarter than in any of those times.
[james28909]: in order for there to be a mutation, there has to be a universe with laws setup that even allow a mutation.
[james28909]: everything past the first two things you piked from my posts are irrelevant to me and my beliefs. they are side effects.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2017-12-15 14:50 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.