String::ProgressBar - Produces a simple progress bar
use String::ProgressBar; my $pr = String::ProgressBar->new( max => 30 ); $pr->update( 10 ); # step 10 of 30 $pr->write; # shows that: # [======= ] 33% [10/30] # If you want to print it by yourself: use String::ProgressBar; my $pr = String::ProgressBar->new( max => 30 ); print $pr->update( 10 )->string()."\r";
The progress bar has a fix matrix and look liket that:
first [====================] 100% [30/30]
It is an OO class to produce a simple progress bar which can be used at a shell. It does not use curses and has no large dependencies.
Carp
my $object = $this->new(max => $int);
Constructor
It can take several key value pairs (here you see also the default values):
length => 20 # length of the bar border_left => '[' # left bracked of the bar border_right => ']', # right bracked of the bar bar => '=', # used element of the bar show_rotation => 0, # if it should show a rotating element show_percent => 1, # show percent show_amount => 1, # show value/max text => '', # text before text bar. If empty, starts on the very left end info => '', # text after the bar print_return => 0, # whether it should return after last value with new line text_length => 14, # length of the text before the bar allow_overflow => 0, # allow values to exceed 100% bar_overflow => 0, # allow bar to exceed normal width when value is over 100%
my $object = $this->info($string);
updates info (after bar) with a new value and returns the object itself.
my $string = $this->string();
returns the bar as simple string, so you may write it by yourself.
my $object = $this->text($string);
updates text (before bar) with a new value and returns the object itself.
$this->update();
updates the bar with a new value and returns the object itself.
$this->write();
Writes the bar to STDOUT.
Andreas Hernitscheck ahernit(AT)cpan.org
You can redistribute it and/or modify it under the conditions of LGPL.
To install String::ProgressBar, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::ProgressBar
CPAN shell
perl -MCPAN -e shell install String::ProgressBar
For more information on module installation, please visit the detailed CPAN module installation guide.