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);