#!/usr/bin/perl -w use strict; $a = 0; while ($a < 5) { print ++$a, "\n"; for $b (1..10) { print "$a $b\n"; } for $b (11, 12) { print "$a $b\n"; } } print "done\n"; #### #!/usr/bin/perl -w use lib "."; use Test; use strict; $a = 0; while ($a < 5) print ++$a, "\n"; for $b (1..10) print "$a $b\n"; for $b (11, 12) print "$a $b\n"; print "done\n"; #### foo bar; baz quux xyzzy blah; moo #### foo { bar; } baz; { quux { xyzzy { blah; } } } moo #### package Test; use strict; use Filter::Simple; FILTER_ONLY code => sub { no warnings; my @lines = split /\n/, $_; my @indents; for (@lines) { my ($indent) = /^(\s*)/; $indent =~ s/\t/12345678/g; $indent = length $indent; if ($indent > $indents[-1]) { s/^/{/; push @indents, $indent; } elsif ($indent < $indents[-1]) { while ($indent < $indents[-1]) { defined pop @indents or last; s/^/}/; } } } $_ = join "\n", @lines; $_ .= "}" x @indents; }; 1;