We don't bite newbies here... much | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I have a number of utilities written in Perl that take a while to complete -- e.g. scaling a large number of digital images. It would be nice to know when the task is finished, but usually the script is too small to warrant extravagant code for monitoring progress. Fortunately, there's Term::ProgressBar. It lets you add a fancy wget/scp-style progress bar to your own ap, with only a few lines of code. Martyn J. Pearce has really made an effort to make things easy for us: For basic usage, you just need to call one function to set up the progress bar and another one to update it. He even threw in ETA (estimated time of arrival) calculation. Let's look at some code. I like the ETA display, so I'm making it a bit more complicated than the very basic usage (two more lines added, horrors!). This is taken from my image scaling script:
The output looks somewhat like this (note: I shortened the output here to make it fit on one code line):
I'm using a German locale, so the script displays 23:35 instead of 11:35pm -- just in case you're wondering. When the estimated time needed is short, the display automatically changes:
I'm using the module on Mac OS X, but it should work on all standard Unix terminals. Not sure whether it works on Windows. In reply to Term::ProgressBar by crenz
|
|