]> git.donarmstrong.com Git - perltidy.git/blobdiff - examples/perlcomment.pl
remove change to bin/perltidy
[perltidy.git] / examples / perlcomment.pl
index b38452d6a894a92b11c49a01c623a9bc3f7a6314..c6143c76b4c2cceae607c086390a1ccde18f9919 100644 (file)
@@ -8,7 +8,7 @@
 #
 # where -l specifies the maximum comment line length.
 #
-# You will be given an opportunity to accept or reject eacy proposed
+# You will be given an opportunity to accept or reject each proposed
 # change.
 #
 # This file demonstrates using Perl::Tidy to walk through a perl 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 (
@@ -224,9 +227,9 @@ sub queryu {
 }
 
 sub ifyes {
-    my $ans   = queryu(@_);
     my $count = 0;
   ASK:
+    my $ans   = queryu(@_);
     if    ( $ans =~ /^Y/ ) { return 1 }
     elsif ( $ans =~ /^N/ ) { return 0 }
     else {