]> git.donarmstrong.com Git - perltidy.git/blobdiff - examples/ex_mp.pl
Imported Upstream version 20120701
[perltidy.git] / examples / ex_mp.pl
diff --git a/examples/ex_mp.pl b/examples/ex_mp.pl
new file mode 100644 (file)
index 0000000..75abc74
--- /dev/null
@@ -0,0 +1,20 @@
+# This example is from the Perl::Tidy man page
+use Perl::Tidy;
+
+# some messy source code to format
+my $source = <<'EOM';
+use strict;
+my @editors=('Emacs', 'Vi   '); my $rand = rand();
+print "A poll of 10 random programmers gave these results:\n";
+foreach(0..10) {
+my $i=int ($rand+rand());
+print " $editors[$i] users are from Venus" . ", " . 
+"$editors[1-$i] users are from Mars" . 
+"\n";
+}
+EOM
+
+# We'll pass it as ref to SCALAR and receive it in a ref to ARRAY
+my @dest;
+perltidy( source => \$source, destination => \@dest );
+foreach (@dest) {print}