X-Git-Url: https://git.donarmstrong.com/?p=perltidy.git;a=blobdiff_plain;f=examples%2Fperlcomment.pl;h=c6143c76b4c2cceae607c086390a1ccde18f9919;hp=e764397491f354668a0311cca11a2e9bba55c2a8;hb=caa9a6008de8bbc9dddfb772bff67005c099d6dd;hpb=b2d8cef8551aa63c2718732e53392e7ebdd6c75f diff --git a/examples/perlcomment.pl b/examples/perlcomment.pl index e764397..c6143c7 100644 --- a/examples/perlcomment.pl +++ b/examples/perlcomment.pl @@ -60,12 +60,15 @@ sub autoformat_file { unless ($fh) { die "cannot open '$file': $!\n" } my $formatter = CommentFormatter->new($line_length); - perltidy( + my $err=perltidy( 'formatter' => $formatter, # callback object 'source' => $fh, 'argv' => "-npro -se", # dont need .perltidyrc # errors to STDOUT ); + if ($err) { + die "Error calling perltidy\n"; + } $fh->close(); } @@ -99,9 +102,9 @@ sub write_line { my $line_of_tokens = shift; my $line_type = $line_of_tokens->{_line_type}; ## my $input_line_number = $line_of_tokens->{_line_number}; - my $input_line = $line_of_tokens->{_line_text}; # the orignal line - my $rtoken_type = $line_of_tokens->{_rtoken_type}; # type of tokens - my $rtokens = $line_of_tokens->{_rtokens}; # text of tokens + my $input_line = $line_of_tokens->{_line_text}; # the original line + my $rtoken_type = $line_of_tokens->{_rtoken_type}; # type of tokens + my $rtokens = $line_of_tokens->{_rtokens}; # text of tokens # Just print non-code, non-comment lines if (