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