]> git.donarmstrong.com Git - perltidy.git/blob - examples/bbtidy.pl
New upstream release 20250105
[perltidy.git] / examples / bbtidy.pl
1 #!/usr/bin/perl -wn
2
3 # This program was posted on the MacPerl mailing list by 
4 # Charles Albrecht as one way to get perltidy to work as a filter
5 # under BBEdit.
6 # 20240102: slh fixed obvious error found with -duv: ('my' inside BEGIN block)
7
8 use Perl::Tidy;
9
10 my ($input_string, $output_string);
11 BEGIN { $input_string = ""; $output_string = ""; }
12
13 $input_string .= $_;
14
15 END {
16     my $err=Perl::Tidy::perltidy(
17         source      => \$input_string,
18         destination => \$output_string
19     );
20     if ($err){
21         die "Error calling perltidy\n";
22     }
23     print "$output_string\n";
24 }
25
26 __END__
27