cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
Instead of filenames the script actually uses I've just given it a couple of counts for the inner loop. In place of the actual processing done on the file contents I've included a sleep.use strict; use feature ':5.10'; use Term::ProgressBar; my @files = qw(30 50); foreach my $f (@files) { my $max = $f; my $progress = Term::ProgressBar->new({name => 'Processed', count +=> $max, remove => 1, ETA => 'linear'}); $progress->max_update_rate(1); $progress->minor(0); my $next_update = 0; foreach my $i (0..$max) { sleep 1; # represents stuff my script is actually processing $next_update = $progress->update($_) if $_ >= $next_update; } $progress->update($max) if $max >= $next_update; }
I'm doing something wrong because the progress bar advances one step and that's it until it completes. To be honest the example code given in the module docs is a little hard for me to follow. I don't understand what is setting $_ so maybe I'm not doing something with that that I shouldbe doing.
Can anyone say what I'm doing wrong?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Term::ProgressBar won't update
by hv (Prior) on Sep 17, 2022 at 20:05 UTC | |
by cormanaz (Deacon) on Sep 17, 2022 at 22:08 UTC | |
by AnomalousMonk (Archbishop) on Sep 17, 2022 at 23:05 UTC | |
Re: Term::ProgressBar won't update
by kcott (Archbishop) on Sep 18, 2022 at 01:00 UTC |