Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I often run scripts that have to run for a while and that do not output anything. So I like to see how they are doing, if they are just sitting there waiting for something to happen, or maybe stuck in an infinite loop. So I use this subroutine to display an indicator of how many times I have been through my main loop on STDOUT.
Its used this way: while(...) { # whatever you have to do progress(); } As I use in various situations the main loop can be run any time from a few hundred to several tens of thousand times, so you can pass a parameter or change the DEFAULT_STEP constant to display a dot for every n loops. After 10 dots a space is printed, and after 50 a new line (those values can also be changed). One last thing: if you want to see the dots displayed as soon as they are generated don't forget to unbuffer the output, for example with $|=1; Oh and if the features of this progress indicator are not what you are looking for, here is a list of previous nodes on that subject:
In reply to Progress indicator by mirod
|
|