File: ex_mp.pl

package info (click to toggle)
perltidy 20031021-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,364 kB
  • ctags: 591
  • sloc: perl: 16,452; makefile: 46
file content (20 lines) | stat: -rw-r--r-- 551 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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}