X-Git-Url: https://git.donarmstrong.com/?p=perltidy.git;a=blobdiff_plain;f=examples%2Fbreak_long_quotes.pl;h=ba40d9a51ec7172efd99436f20cbd75094adcd86;hp=66c58a652abea41bcbca1c1d07c3ab28ad4f7c74;hb=caa9a6008de8bbc9dddfb772bff67005c099d6dd;hpb=b2d8cef8551aa63c2718732e53392e7ebdd6c75f diff --git a/examples/break_long_quotes.pl b/examples/break_long_quotes.pl index 66c58a6..ba40d9a 100644 --- a/examples/break_long_quotes.pl +++ b/examples/break_long_quotes.pl @@ -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')