--- /dev/null
+#!/usr/bin/perl\r
+use strict;\r
+use warnings;\r
+\r
+use Term::ProgressBar 2.00;\r
+\r
+use constant MAX => 100_000;\r
+\r
+my $progress = Term::ProgressBar->new(MAX);\r
+\r
+for (0..MAX) {\r
+ my $is_power = 0;\r
+ for(my $i = 0; 2**$i <= $_; $i++) {\r
+ $is_power = 1\r
+ if 2**$i == $_;\r
+ }\r
+\r
+ if ( $is_power ) {\r
+ $progress->update($_);\r
+ }\r
+}\r
--- /dev/null
+#!/usr/bin/perl\r
+use strict;\r
+use warnings;\r
+\r
+use Term::ProgressBar 2.00;\r
+\r
+my $max = shift || 100;\r
+\r
+my $progress = Term::ProgressBar->new($max);\r
+\r
+for (0..$max) {\r
+ my $is_power = 0;\r
+ for(my $i = 0; 2**$i <= $_; $i++) {\r
+ $is_power = 1\r
+ if 2**$i == $_;\r
+ }\r
+\r
+ $progress->update($_)\r
+}\r
}
}
+see eg/simle_use.pl
+
Here is a simple example. The process considers all the numbers between 0 and
MAX, and updates the progress bar whenever it finds one. Note that the
progress bar update will be very erratic. See below for a smoother example.
$progress->update($_)
}
+See eg/smooth_bar.pl
+
This example calls update for each value considered. This will result in a
much smoother progress update, but more program time is spent updating the bar
than doing the "real" work. See below to remedy this. This example does