Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: overwrite last line printed

by SuicideJunkie (Vicar)
on Nov 28, 2011 at 14:39 UTC ( [id://940405]=note: print w/replies, xml ) Need Help??


in reply to Re^4: overwrite last line printed
in thread overwrite last line printed

For a scheme that is mostly independent of the time-per-iteration, and optimized for users:

if ($lastPrintTime != time) { $lastPrintTime = time; printf("Reticulating Splines: (%3d%%)\r", 100 * $loopIndex / $totalW +ork); }
That gets you a print only once per second (sometimes two seconds). Plenty often for humans, but almost never to the computer.

I'm usually lazier than that, and just slap on a cheap modulo conditional after seeing how long the loop iterations take:

printf("Evaluating Widgets: (%3d%%)\r", 100 * $loopIndex / $totalWork) unless ($loopIndex % 200);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found