]> git.donarmstrong.com Git - perltidy.git/blobdiff - examples/perlcomment.pl
Imported Upstream version 20130922
[perltidy.git] / examples / perlcomment.pl
index e764397491f354668a0311cca11a2e9bba55c2a8..c6143c76b4c2cceae607c086390a1ccde18f9919 100644 (file)
@@ -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 (