NAME
Term::ProgressBar::Simple - simpler progress bars
SYNOPSIS
# create some things to loop over
my @things = (...);
my $number_of_things = scalar @things;
# create the progress bar object
my $progress = Term::ProgressBar::Simple->new( $number_of_things );
# loop
foreach my $thing (@things) {
# do some work
$thing->do_something();
# increment the progress bar object to tell it a step has been taken.
$progress++;
}
DESCRIPTION
Progress bars are handy - they tell you how much work has been done, how much is left to do and estimate how long it will take.
But they can be fiddly!
This module does the right thing in almost all cases in a really convenient way.
FEATURES
Lots - does all the best practice:
Wraps Term::ProgressBar::Quiet so there is no output unless the code is running interactively - lets you put them in cron scripts.
Deals with minor updates - only refreshes the screen when it will change what the user sees so it is efficient.
Completes the progress bar when the progress object is destroyed (explicitly or by going out of scope) - no more '99%' done.
METHODS
new
# Either...
my $progress = Term::ProgressBar::Simple->new($count);
# ... or
my $progress = Term::ProgressBar::Simple->new(
{
count => $count, #
name => 'descriptive text',
}
);
Create a new progress bar. Either just pass in the number of things to do, or a config hash. See Term::ProgressBar for details.
increment ( ++ )
$progress++;
Incrementing the object causes the progress display to be updated. It is smart about checking to see if the display needs to be updated.
SEE ALSO
Term::ProgressBar & Term::ProgressBar::Quiet
GOTCHAS
Not all operators are overloaded, so things might blow up in interesting ways. Patches welcome.
THANKS
Leon Brocard for doing the hard work in Term::ProgressBar::Quiet.
YAPC::EU::2008 for providing the venue and coffee.
AUTHOR
Edmund von der Burg <evdb@ecclestoad.co.uk>
.
BUGS
There are no tests - ther should be. The smart way would be to trap the output and check it is right.
LICENCE AND COPYRIGHT
Copyright (c) 2008, Edmund von der Burg <evdb@ecclestoad.co.uk>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.