The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
use strict;
use warnings;

use Term::ProgressBar 2.00;

use constant MAX => 100_000;

my $max = int($ARGV[0] || MAX);
my $progress = Term::ProgressBar->new({
	name => 'Powers',
	count => $max,
	remove => 3,
});
$progress->minor(0);
my $next_update = 0;

for (0..$max) {
  my $is_power = 0;
  for(my $i = 0; 2**$i <= $_; $i++) {
    $is_power = 1
      if 2**$i == $_;
  }

  $next_update = $progress->update($_)
    if $_ > $next_update;
}
$progress->update($max)
    if $max >= $next_update;