in reply to Automate perltidy for PM code?
No need for piping through perltidy, Perl::Tidy with the right config can do the trick.
Update:
#!/usr/bin/perl use strict; use warnings; use Perl::Tidy; my $input = <<'_EOT'; sub Tidy { my ( $text, $cmdopt ) = @_; my $tmpfile = "/tmp/Tidy.$$." . join( '', localtime()) ."tmp"; open my $th, ">$tmpfile" or die; print $th $text or die; close $th or die; my $pid = open my $ph, "perltidy -st $cmdopt $tmpfile |" or die; my $tidied = join '', <$ph>; close $ph or die; waitpid $pid, 0; unlink $tmpfile; return $tidied; } _EOT my $output; Perl::Tidy::perltidy( source => \$input, destination => \$output, ); print $output;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Automate perltidy for PM code?
by Moron (Curate) on Jul 09, 2007 at 15:35 UTC | |
by derby (Abbot) on Jul 09, 2007 at 17:18 UTC |