.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Term::ProgressBar::Simple 3pm" .TH Term::ProgressBar::Simple 3pm "2021-01-01" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Term::ProgressBar::Simple \- simpler progress bars .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # 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 \*(Aq$progress += $number\*(Aq later in pod .Ve .SH "DESCRIPTION" .IX Header "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. .PP But they can be fiddly! .PP This module does the right thing in almost all cases in a really convenient way. .SH "FEATURES" .IX Header "FEATURES" Lots \- does all the best practice: .PP Wraps Term::ProgressBar::Quiet so there is no output unless the code is running interactively \- lets you put them in cron scripts. .PP Deals with minor updates \- only refreshes the screen when it will change what the user sees so it is efficient. .PP Completes the progress bar when the progress object is destroyed (explicitly or by going out of scope) \- no more '99%' done. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 2 \& # Either... \& my $progress = Term::ProgressBar::Simple\->new($count); \& \& # ... or \& my $progress = Term::ProgressBar::Simple\->new( \& { \& count => $count, # \& name => \*(Aqdescriptive text\*(Aq, \& } \& ); .Ve .PP Create a new progress bar. Either just pass in the number of things to do, or a config hash. See Term::ProgressBar for details. .SS "increment ( ++ )" .IX Subsection "increment ( ++ )" .Vb 1 \& $progress++; .Ve .PP Incrementing the object causes the progress display to be updated. It is smart about checking to see if the display needs to be updated. .SS "increment ( += )" .IX Subsection "increment ( += )" .Vb 1 \& $progress += $number_done; .Ve .PP Sometimes you'll have done more than one step between updates. A good example is processing 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: .PP .Vb 2 \& # 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; \& } .Ve .SS "message" .IX Subsection "message" .Vb 1 \& $progress\->message(\*(AqCopying $filename\*(Aq); .Ve .PP Output a message. This is very much like print, but we try not to disturb the terminal. .SH "SEE ALSO" .IX Header "SEE ALSO" Term::ProgressBar & Term::ProgressBar::Quiet .SH "GOTCHAS" .IX Header "GOTCHAS" Not all operators are overloaded, so things might blow up in interesting ways. Patches welcome. .SH "THANKS" .IX Header "THANKS" Martyn J. Pearce for the orginal and great Term::ProgressBar. .PP Leon Brocard for doing the hard work in Term::ProgressBar::Quiet, and for submitting a patch with the code for \f(CW\*(C`+=\*(C'\fR.. .PP \&\s-1YAPC::EU::2008\s0 for providing the venue and coffee whilst the first version of this module was written. .SH "AUTHOR" .IX Header "AUTHOR" Edmund von der Burg \f(CW\*(C`\*(C'\fR. .PP .SH "BUGS" .IX Header "BUGS" There are no tests \- there should be. The smart way would be to trap the output and check it is right. .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright (c) 2008, Edmund von der Burg \f(CW\*(C`\*(C'\fR. All rights reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.