]> git.donarmstrong.com Git - term-progressbar.git/commitdiff
copy two examples from the docs to the eg directory
authorGabor Szabo <gabor@szabgab.com>
Tue, 29 Nov 2011 15:49:13 +0000 (17:49 +0200)
committerGabor Szabo <gabor@szabgab.com>
Tue, 29 Nov 2011 15:49:13 +0000 (17:49 +0200)
eg/simple_use.pl [new file with mode: 0644]
eg/smooth_bar.pl [new file with mode: 0644]
lib/Term/ProgressBar.pm

diff --git a/eg/simple_use.pl b/eg/simple_use.pl
new file mode 100644 (file)
index 0000000..6d57747
--- /dev/null
@@ -0,0 +1,21 @@
+#!/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
diff --git a/eg/smooth_bar.pl b/eg/smooth_bar.pl
new file mode 100644 (file)
index 0000000..befae9a
--- /dev/null
@@ -0,0 +1,19 @@
+#!/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
index f1ed1dc1e3fe3b1414d32ec18a803a44000464b3..84ed9b805b203e6bd7ebaa5942aea836579435f7 100644 (file)
@@ -75,6 +75,8 @@ bar for the same width.
     }
   }
 
+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.
@@ -97,6 +99,8 @@ distribution set (it is not installed as part of the module).
     $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