Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Dynamically printing out iteration number from foreach loop

by frozenwithjoy (Curate)
on Jun 21, 2013 at 21:17 UTC ( #1040223=note: print w/ replies, xml ) Need Help??


in reply to Dynamically printing out iteration number from foreach loop

This is happening because the output is being buffered. You can turn on the auto-flush for the buffer by adding the following somewhere in your script before what you want to be unbuffered:

$| = 1;

$| = 0; reverts everything back to normal. If you want to get more complicated, you can try IO::Handle, but it is probably overkill for what you need.


Comment on Re: Dynamically printing out iteration number from foreach loop
Select or Download Code
Replies are listed 'Best First'.
Re^2: Dynamically printing out iteration number from foreach loop
by kennethk (Abbot) on Jun 21, 2013 at 21:46 UTC
    You omitted the obligatory Suffering from Buffering.

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re^2: Dynamically printing out iteration number from foreach loop
by hyu968 (Initiate) on Jun 21, 2013 at 21:24 UTC
    Awesome, thanks!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-07 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls