Subject: | Use of uninitialized value $name in printf if not output to a terminal |
Howdy.
Attached is a slightly modified version of example/simple_use.pl with term => 0 which illustrates the bug.
Upon running it, I get the folowing output:
se of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 0%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 1%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 2%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 4%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 8%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 16%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:42 2017] : 32%
Use of uninitialized value $name in printf at [...]/lib/site_perl/5.22.1/Term/ProgressBar.pm line 937.
[Tue Oct 31 14:34:43 2017] : 65%
Subject: | simple_use.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Term::ProgressBar 2.00;
use constant MAX => 100_000;
my $progress = Term::ProgressBar->new({ term => 0, count => MAX });
for (0..MAX) {
my $is_power = 0;
for(my $i = 0; 2**$i <= $_; $i++) {
$is_power = 1
if 2**$i == $_;
}
if ( $is_power ) {
$progress->update($_);
}
}