]> git.donarmstrong.com Git - perltidy.git/blobdiff - examples/break_long_quotes.pl
Imported Upstream version 20130922
[perltidy.git] / examples / break_long_quotes.pl
index 66c58a652abea41bcbca1c1d07c3ab28ad4f7c74..ba40d9a51ec7172efd99436f20cbd75094adcd86 100644 (file)
@@ -51,12 +51,15 @@ sub scan_file {
     unless ($fh) { die "cannot open '$file': $!\n" }
     my $formatter = MyWriter->new($line_length);
 
-    perltidy(
+    my $err=perltidy(
         'formatter' => $formatter,     # callback object
         'source'    => $fh,
-        'argv'      => "-npro -se",    # dont need .perltidyrc
+        'argv'      => "-npro -se",    # don't need .perltidyrc
                                        # errors to STDOUT
     );
+    if ($err){
+        die "Error calling perltidy\n";
+    }
     $fh->close();
 } ## end sub scan_file
 
@@ -88,11 +91,11 @@ 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
     my $starting_in_quote =
-      $line_of_tokens->{_starting_in_quote};                  # text of tokens
+      $line_of_tokens->{_starting_in_quote};                 # text of tokens
     my $ending_in_quote  = $line_of_tokens->{_ending_in_quote}; # text of tokens
     my $max_quote_length = $self->{_max_quote_length};
     chomp $input_line;
@@ -140,7 +143,7 @@ EOM
             $new_line .= $token;
         } ## end for ( my $j = 0 ; $j <=...
 
-        # substitude the modified line for the original line
+        # substitute the modified line for the original line
         $input_line = $new_line;
     } ## end if ( $line_type eq 'CODE')