]> git.donarmstrong.com Git - term-progressbar.git/blobdiff - eg/smooth_bar.pl
copy two examples from the docs to the eg directory
[term-progressbar.git] / eg / smooth_bar.pl
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