SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG
DONATE




YUM REPOSITORY

 
 

MAN page from Mandriva 2010 perl-Term-ProgressBar-Simple-0.30.0-1mdv2010.1.noarch.rpm

Term::ProgressBar::Simple

Section: User Contributed Perl Documentation (3)
Updated: 2009-02-24
Index 

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++;    }    # See also use of '$progress += $number' later in pod
 

DESCRIPTION

Progress bars are handy - they tell you how much work has been done, how much isleft 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 isrunning interactively - lets you put them in cron scripts.

Deals with minor updates - only refreshes the screen when it will change whatthe user sees so it is efficient.

Completes the progress bar when the progress object is destroyed (explicitly orby 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 aconfig hash. See Term::ProgressBar for details. 

increment ( ++ )

    $progress++;

Incrementing the object causes the progress display to be updated. It is smartabout checking to see if the display needs to be updated. 

increment ( += )

    $progress += $number_done;

Sometimes you'll have done more than one step between updates. A good example isprocessing logfiles, where the time taken is relative to the size of the file.In this case code like this would give a better feel for the progress made:

    # Get the total size of all the files    my $total_size = sum map { -s } @filenames;    # Set up object with total size as steps to do    my $progress = Term::ProgressBar::Simple->new($total_size);    # process each file and increment by the size of each file    foreach my $filename (@filenames) {        process_the_file($filename);        $progress += -s $filename;    }
 

message

    $progress->message('Copying $filename');

Output a message. This is very much like print, but we try not todisturb the terminal. 

SEE ALSO

Term::ProgressBar & Term::ProgressBar::Quiet 

GOTCHAS

Not all operators are overloaded, so things might blow up in interesting ways.Patches welcome. 

THANKS

Martyn J. Pearce for the orginal and great Term::ProgressBar.

Leon Brocard for doing the hard work in Term::ProgressBar::Quiet, and forsubmitting a patch with the code for "+="..

YAPC::EU::2008 for providing the venue and coffee whilst the first version ofthis module was written. 

AUTHOR

Edmund von der Burg "<evdbAATTecclestoad.co.uk>".

<http://www.ecclestoad.co.uk/> 

BUGS

There are no tests - there should be. The smart way would be to trap the outputand check it is right. 

LICENCE AND COPYRIGHT

Copyright (c) 2008, Edmund von der Burg "<evdbAATTecclestoad.co.uk>".All rights reserved.

This module is free software; you can redistribute it and/or modify it underthe same terms as Perl itself.


 

Index

NAME
SYNOPSIS
DESCRIPTION
FEATURES
METHODS
new
increment ( ++ )
increment ( += )
message
SEE ALSO
GOTCHAS
THANKS
AUTHOR
BUGS
LICENCE AND COPYRIGHT

This document was created byman2html,using the manual pages.