]> git.donarmstrong.com Git - term-progressbar.git/blob - examples/powers2
use strict; use warnings; in examples
[term-progressbar.git] / examples / powers2
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Term::ProgressBar 2.00;
6
7 use constant MAX => 100_000;
8
9 my $max = int($ARGV[0] || MAX);
10 my $progress = Term::ProgressBar->new($max);
11
12 for (0..$max) {
13   my $is_power = 0;
14   for(my $i = 0; 2**$i <= $_; $i++) {
15     $is_power = 1
16       if 2**$i == $_;
17   }
18
19   $progress->update($_);
20 }