]> git.donarmstrong.com Git - perltidy.git/commitdiff
make all print filehandles braced
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 21 Aug 2023 17:59:43 +0000 (10:59 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 21 Aug 2023 17:59:43 +0000 (10:59 -0700)
This can now be checked with perlcritic

14 files changed:
.perlcriticrc
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy.pm
lib/Perl/Tidy/Diagnostics.pm
lib/Perl/Tidy/FileWriter.pm
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/HtmlWriter.pm
lib/Perl/Tidy/IOScalar.pm
lib/Perl/Tidy/IOScalarArray.pm
lib/Perl/Tidy/IndentationItem.pm
lib/Perl/Tidy/Logger.pm
lib/Perl/Tidy/Tokenizer.pm
lib/Perl/Tidy/VerticalAligner.pm
lib/Perl/Tidy/VerticalAligner/Alignment.pm

index 61d59dd0441a28ad53c5a94006d29e7f12cec623..88ed59d85c2a5862c2ed267d02000178b179861e 100644 (file)
@@ -187,11 +187,6 @@ max_nests=9
 # it as a general rule:
 [-NamingConventions::Capitalization]
 
-# It would be nice if this option were configurable to skip STDERR and STDOUT
-# which are used by perltidy almost exclusively for debug statements.
-# I may eventually convert to braced {*STDOUT}, but must skip it for now.
-[-InputOutput::RequireBracedFileHandleWithPrint]
-
 # PerlCritic should not suggest this policy for complex sorts because it can
 # change program behavior when a stable sort has been assumed.  And it does not
 # even make sense for sorts on multiple keys, like this one which got flagged
index 1a47deee45f599dade7865ff169a6c4f71ced8c3..8f81fc699a1f7fff73d29ca12ddbae72cfcf1e8f 100644 (file)
@@ -9709,7 +9709,9 @@ my $parser =
 foreach
           my $name
           (
-    param $query)
+    param
+              $query
+          )
 
 __END__
 
index 876e90a3fb6220b5596fa0e79cf3343a4a1ccb4c..7ccab2d666f59b35f122b63c1f9cfabd58dd310b 100644 (file)
@@ -127,7 +127,7 @@ sub AUTOLOAD {
     our $AUTOLOAD;
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Unexpected call to Autoload looking for sub $AUTOLOAD
 Called from package: '$pkg'  
@@ -877,7 +877,7 @@ EOM
 
     # dump from command line
     if ( $rOpts->{'dump-options'} ) {
-        print STDOUT $readable_options;
+        print {*STDOUT} $readable_options;
         Exit(0);
     }
 
@@ -2729,7 +2729,7 @@ BLINKER. Output for iteration $iter same as for $saw_md5{$digest}.
 EOM
                         $stopping_on_error ||= $convergence_log_message;
                         DEVEL_MODE
-                          && print STDERR $convergence_log_message;
+                          && print {*STDERR} $convergence_log_message;
                         $diagnostics_object->write_diagnostics(
                             $convergence_log_message)
                           if $diagnostics_object;
@@ -2760,12 +2760,12 @@ EOM
                         # convergence test above is temporarily skipped for
                         # testing.
                         if ( $iteration_of_formatter_convergence < $iter - 1 ) {
-                            print STDERR
+                            print {*STDERR}
 "STRANGE Early conv in $display_name: Stopping on it=$iter, converged in formatter on $iteration_of_formatter_convergence\n";
                         }
                     }
                     elsif ( !$stopping_on_error ) {
-                        print STDERR
+                        print {*STDERR}
 "STRANGE no conv in $display_name: stopping on it=$iter, but not converged in formatter\n";
                     }
                 }
@@ -4799,7 +4799,7 @@ DIE
 # Debug routine -- this will dump the expansion hash
 sub dump_short_names {
     my $rexpansion = shift;
-    print STDOUT <<EOM;
+    print {*STDOUT} <<EOM;
 List of short names.  This list shows how all abbreviations are
 translated into other abbreviations and, eventually, into long names.
 New abbreviations may be defined in a .perltidyrc file.  
@@ -4808,7 +4808,7 @@ For a list of all long names, use perltidy --dump-long-names (-dln).
 EOM
     foreach my $abbrev ( sort keys %{$rexpansion} ) {
         my @list = @{ $rexpansion->{$abbrev} };
-        print STDOUT "$abbrev --> @list\n";
+        print {*STDOUT} "$abbrev --> @list\n";
     }
     return;
 } ## end sub dump_short_names
@@ -5113,14 +5113,14 @@ sub Win_Config_Locs {
 
 sub dump_config_file {
     my ( $rconfig_string, $config_file, $rconfig_file_chatter ) = @_;
-    print STDOUT "${$rconfig_file_chatter}";
+    print {*STDOUT} "${$rconfig_file_chatter}";
     if ($rconfig_string) {
         my @lines = split /^/, ${$rconfig_string};
-        print STDOUT "# Dump of file: '$config_file'\n";
-        while ( defined( my $line = shift @lines ) ) { print STDOUT $line }
+        print {*STDOUT} "# Dump of file: '$config_file'\n";
+        while ( defined( my $line = shift @lines ) ) { print {*STDOUT} $line }
     }
     else {
-        print STDOUT "# ...no config file found\n";
+        print {*STDOUT} "# ...no config file found\n";
     }
     return;
 } ## end sub dump_config_file
@@ -5370,7 +5370,7 @@ EOM
 sub dump_long_names {
 
     my @names = @_;
-    print STDOUT <<EOM;
+    print {*STDOUT} <<EOM;
 # Command line long names (passed to GetOptions)
 #--------------------------------------------------
 # here is a summary of the Getopt codes:
@@ -5386,14 +5386,14 @@ sub dump_long_names {
 #--------------------------------------------------
 EOM
 
-    foreach my $name ( sort @names ) { print STDOUT "$name\n" }
+    foreach my $name ( sort @names ) { print {*STDOUT} "$name\n" }
     return;
 } ## end sub dump_long_names
 
 sub dump_defaults {
     my @defaults = @_;
-    print STDOUT "Default command line options:\n";
-    foreach my $line ( sort @defaults ) { print STDOUT "$line\n" }
+    print {*STDOUT} "Default command line options:\n";
+    foreach my $line ( sort @defaults ) { print {*STDOUT} "$line\n" }
     return;
 } ## end sub dump_defaults
 
@@ -5443,7 +5443,7 @@ sub readable_options {
 } ## end sub readable_options
 
 sub show_version {
-    print STDOUT <<"EOM";
+    print {*STDOUT} <<"EOM";
 This is perltidy, v$VERSION 
 
 Copyright 2000-2023, Steve Hancock
@@ -5459,7 +5459,7 @@ EOM
 
 sub usage {
 
-    print STDOUT <<EOF;
+    print {*STDOUT} <<EOF;
 This is perltidy version $VERSION, a perl script indenter.  Usage:
 
     perltidy [ options ] file1 file2 file3 ...
index ba5137c91ae820934e03fb251cbc8841301eee84..60f7a998c8914686aa2e25e02f43506bdd6b2b3f 100644 (file)
@@ -31,7 +31,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index d27ef98d918934a881c78a4f7b8403e507b313db..f9596efd29d750461f2fb7a06349827016ae047c 100644 (file)
@@ -21,7 +21,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index 7708609c083e2ead6e31c5cd3ef3ebd230a9d946..122edf10f7699b50d6743f44b708928f0afe90a1 100644 (file)
@@ -67,7 +67,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
@@ -3472,7 +3472,7 @@ sub set_whitespace_flags {
         if ( !defined($ws_2) ) { $ws_2 = "*" }
         if ( !defined($ws_3) ) { $ws_3 = "*" }
         if ( !defined($ws_4) ) { $ws_4 = "*" }
-        print STDOUT
+        print {*STDOUT}
 "NEW WHITE:  i=$j $str $last_type_dbg $type $ws_1 : $ws_2 : $ws_3 : $ws_4 : $ws \n";
 
         # reset for next pass
@@ -4926,7 +4926,7 @@ EOM
               && $bond_str_1 != $bond_str_2
               && $bond_str_2 != $tabulated_bond_str
               && do {
-                print STDERR
+                print {*STDOUT}
 "BOND_TABLES: ltype=$ltype rtype=$rtype $bond_str_1->$bond_str_2->$bond_str_3\n";
               };
 
@@ -5050,7 +5050,7 @@ EOM
             DEBUG_BOND && do {
                 my $str = substr( $token, 0, 15 );
                 $str .= SPACE x ( 16 - length($str) );
-                print STDOUT
+                print {*STDOUT}
 "BOND:  i=$i $str $type $next_nonblank_type depth=$total_nesting_depth strength=$bond_str_1 -> $bond_str_2 -> $bond_str_3 -> $bond_str_4 $bond_str -> $strength \n";
 
                 # reset for next pass
@@ -6790,12 +6790,12 @@ sub dump_block_summary {
     # Sort blocks and packages on starting line number
     my @sorted_lines = sort { $a->[1] <=> $b->[1] } @{$routput_lines};
 
-    print STDOUT
+    print {*STDOUT}
 "file,line,line_count,code_lines,type,name,level,max_change,block_count,mccabe_count\n";
 
     foreach my $rline_vars (@sorted_lines) {
         my $line = join( ",", @{$rline_vars} ) . "\n";
-        print STDOUT $line;
+        print {*STDOUT} $line;
     }
     return;
 } ## end sub dump_block_summary
@@ -7571,7 +7571,7 @@ lno\tci\tci_this\tci_next\tlast_type\tlast_tok\ttype\ttok\tseqno\tlevel\tpname\t
 EOM
             foreach my $line (@output_lines) {
                 chomp $line;
-                print STDERR $line, "\n";
+                print {*STDOUT} $line, "\n";
             }
         }
     }
@@ -11856,7 +11856,7 @@ EOM
         {
             if (DEBUG_WELD) {
                 $Msg .= "RULE 0: Not welding due to sheared inner parens\n";
-                print $Msg;
+                print {*STDOUT} $Msg;
             }
             next;
         }
@@ -11886,7 +11886,7 @@ EOM
                     || $iline_ic != $iline_oc )
               )
             {
-                if (DEBUG_WELD) { print $msg}
+                if (DEBUG_WELD) { print {*STDOUT} $msg }
                 next;
             }
 
@@ -12198,7 +12198,7 @@ EOM
 
             if (DEBUG_WELD) {
                 $Msg .= "Not welding due to RULE $do_not_weld_rule\n";
-                print $Msg;
+                print {*STDOUT} $Msg;
             }
 
             # Normally, a broken pair should not decrease indentation of
@@ -12219,7 +12219,7 @@ EOM
             $weld_count_this_start++;
             if (DEBUG_WELD) {
                 $Msg .= "Starting new weld\n";
-                print $Msg;
+                print {*STDOUT} $Msg;
             }
             push @welds, $item;
 
@@ -12239,7 +12239,7 @@ EOM
             $weld_count_this_start++;
             if (DEBUG_WELD) {
                 $Msg .= "Extending current weld\n";
-                print $Msg;
+                print {*STDOUT} $Msg;
             }
             unshift @{ $welds[-1] }, $inner_seqno;
             $rK_weld_right->{$Kouter_opening} = $Kinner_opening;
@@ -12425,7 +12425,7 @@ sub weld_nested_quotes {
               = $self->setup_new_weld_measurements( $Kouter_opening,
                 $Kinner_opening );
             if ( !$ok_to_weld ) {
-                if (DEBUG_WELD) { print $msg}
+                if (DEBUG_WELD) { print {*STDOUT} $msg }
                 next;
             }
 
@@ -12483,7 +12483,7 @@ sub weld_nested_quotes {
             if ($do_not_weld) {
                 if (DEBUG_WELD) {
                     $Msg .= "Not Welding QW\n";
-                    print $Msg;
+                    print {*STDOUT} $Msg;
                 }
                 next;
             }
@@ -12491,7 +12491,7 @@ sub weld_nested_quotes {
             # OK to weld
             if (DEBUG_WELD) {
                 $Msg .= "Welding QW\n";
-                print $Msg;
+                print {*STDOUT} $Msg;
             }
 
             $rK_weld_right->{$Kouter_opening} = $Kinner_opening;
@@ -13043,7 +13043,7 @@ sub break_before_list_opening_containers {
           && $rlec_count_by_seqno->{$seqno};
 
         DEBUG_BBX
-          && print STDOUT
+          && print {*STDOUT}
 "BBX: Looking at seqno=$seqno, token = $token with option=$break_option\n";
 
         # -bbx=1 = stable, try to follow input
@@ -13085,12 +13085,12 @@ sub break_before_list_opening_containers {
 
             if ( !$ok_to_break ) {
                 DEBUG_BBX
-                  && print STDOUT "Not breaking at seqno=$seqno: $Msg\n";
+                  && print {*STDOUT} "Not breaking at seqno=$seqno: $Msg\n";
                 next;
             }
 
             DEBUG_BBX
-              && print STDOUT "OK to break at seqno=$seqno: $Msg\n";
+              && print {*STDOUT} "OK to break at seqno=$seqno: $Msg\n";
 
             # Patch: turn off -xci if -bbx=2 and -lp
             # This fixes cases b1090 b1095 b1101 b1116 b1118 b1121 b1122
@@ -13112,7 +13112,7 @@ sub break_before_list_opening_containers {
         # sub insert_breaks_before_list_opening_containers
         $rbreak_before_container_by_seqno->{$seqno} = 1;
         DEBUG_BBX
-          && print STDOUT "BBX: ok to break at seqno=$seqno\n";
+          && print {*STDOUT} "BBX: ok to break at seqno=$seqno\n";
 
         # -bbxi=0: Nothing more to do if the ci value remains unchanged
         my $ci_flag = $container_indentation_options{$token};
@@ -13182,7 +13182,7 @@ sub break_before_list_opening_containers {
                 next unless ($rtype_count);
                 my $fat_comma_count = $rtype_count->{'=>'};
                 DEBUG_BBX
-                  && print STDOUT "BBX: fat comma count=$fat_comma_count\n";
+                  && print {*STDOUT} "BBX: fat comma count=$fat_comma_count\n";
                 if ( $fat_comma_count && $fat_comma_count >= 2 ) { $OK = 1 }
             }
 
@@ -13198,14 +13198,14 @@ sub break_before_list_opening_containers {
                   $self->cumulative_length_before_K($KK);
                 my $excess_length = $length - $maximum_text_length;
                 DEBUG_BBX
-                  && print STDOUT
+                  && print {*STDOUT}
 "BBX: excess=$excess_length: maximum_text_length=$maximum_text_length, length=$length, ci=$ci\n";
 
                 # OK if the net container definitely breaks on length
                 if ( $excess_length > $length_tol ) {
                     $OK = 1;
                     DEBUG_BBX
-                      && print STDOUT "BBX: excess_length=$excess_length\n";
+                      && print {*STDOUT} "BBX: excess_length=$excess_length\n";
                 }
 
                 # Otherwise skip it
@@ -13217,7 +13217,7 @@ sub break_before_list_opening_containers {
         # Part 3: Looks OK: apply -bbx=n and any related -bbxi=n flag
         #------------------------------------------------------------
 
-        DEBUG_BBX && print STDOUT "BBX: OK to break\n";
+        DEBUG_BBX && print {*STDOUT} "BBX: OK to break\n";
 
         # -bbhbi=n
         # -bbsbi=n
@@ -13594,7 +13594,7 @@ sub find_multiline_qw {
 
             # shouldn't happen
             if ( $type ne 'q' ) {
-                DEVEL_MODE && print STDERR <<EOM;
+                DEVEL_MODE && print {*STDERR} <<EOM;
 STRANGE: started multiline qw at K=$K_start_multiline_qw but didn't see q qw at K=$Kfirst\n";
 EOM
                 $K_start_multiline_qw = undef;
@@ -15773,7 +15773,7 @@ EOM
 
         DEBUG_STORE && do {
             my ( $a, $b, $c ) = caller();
-            print STDOUT
+            print {*STDOUT}
 "STORE: from $a $c: storing token $token type $type lev=$level at $max_index_to_go\n";
         };
         return;
@@ -17534,7 +17534,7 @@ EOM
 " Also set closing breakpoint corresponding to this token\n";
                 }
             }
-            print STDOUT $msg;
+            print {*STDOUT} $msg;
         };
 
         return $i_nonblank;
@@ -17645,7 +17645,7 @@ EOM
 
                 DEBUG_UNDOBP && do {
                     my ( $a, $b, $c ) = caller();
-                    print STDOUT
+                    print {*STDOUT}
 "UNDOBP: undo forced_breakpoint i=$i $forced_breakpoint_undo_count from $a $c max=$max_index_to_go\n";
                 };
             }
@@ -17847,7 +17847,7 @@ EOM
                 $output_str = join EMPTY_STRING,
                   @tokens_to_go[ 0 .. $max_index_to_go ];
             }
-            print STDERR <<EOM;
+            print {*STDOUT} <<EOM;
 grind got batch number $batch_count with $max_index_to_go tokens, last type '$type' tok='$token', text:
 $output_str
 EOM
@@ -19090,7 +19090,7 @@ sub break_equals {
         # $ri_beg = ref to array of BEGinning indexes of each line
         # $ri_end = ref to array of ENDing indexes of each line
         my ( $self, $ri_beg, $ri_end, $msg ) = @_;
-        print STDERR "----Dumping breakpoints from: $msg----\n";
+        print {*STDOUT} "----Dumping breakpoints from: $msg----\n";
         for my $n ( 0 .. @{$ri_end} - 1 ) {
             my $ibeg = $ri_beg->[$n];
             my $iend = $ri_end->[$n];
@@ -19098,9 +19098,9 @@ sub break_equals {
             foreach my $i ( $ibeg .. $iend ) {
                 $text .= $tokens_to_go[$i];
             }
-            print STDERR "$n ($ibeg:$iend) $text\n";
+            print {*STDOUT} "$n ($ibeg:$iend) $text\n";
         }
-        print STDERR "----\n";
+        print {*STDOUT} "----\n";
         return;
     } ## end sub Debug_dump_breakpoints
 
@@ -19283,22 +19283,22 @@ sub break_equals {
         my $num_sections = @{$rsections};
 
         if ( DEBUG_RECOMBINE > 1 ) {
-            print STDERR <<EOM;
+            print {*STDOUT} <<EOM;
 sections=$num_sections; nmax_sec=$nmax_section
 EOM
         }
 
         if ( DEBUG_RECOMBINE > 0 ) {
             my $max = 0;
-            print STDERR
+            print {*STDOUT}
               "-----\n$num_sections sections found for nmax=$nmax_start\n";
             foreach my $sect ( @{$rsections} ) {
                 my ( $nbeg, $nend ) = @{$sect};
                 my $num = $nend - $nbeg;
                 if ( $num > $max ) { $max = $num }
-                print STDERR "$nbeg $nend\n";
+                print {*STDOUT} "$nbeg $nend\n";
             }
-            print STDERR "max size=$max of $nmax_start lines\n";
+            print {*STDOUT} "max size=$max of $nmax_start lines\n";
         }
 
         # Loop over all sub-sections.  Note that we have to work backwards
@@ -19487,7 +19487,7 @@ EOM
 
         if (DEBUG_RECOMBINE) {
             my $ratio = sprintf "%0.3f", $rhash->{_num_compares} / $num_pairs;
-            print STDERR
+            print {*STDOUT}
 "exiting recombine_inner_loop with $nmax_last lines, opt=$rhash->{_optimization_on}, starting pairs=$num_pairs, num_compares=$rhash->{_num_compares}, ratio=$ratio\n";
         }
 
@@ -19594,7 +19594,7 @@ EOM
             my $type_ibeg_2 = $types_to_go[$ibeg_2];
 
             DEBUG_RECOMBINE > 1 && do {
-                print STDERR
+                print {*STDOUT}
 "RECOMBINE: ix=$ix iend1=$iend_1 iend2=$iend_2 n=$n nmax=$nmax if=$ibeg_1 type=$type_ibeg_1 =$tokens_to_go[$ibeg_1] next_type=$type_ibeg_2 next_tok=$tokens_to_go[$ibeg_2]\n";
             };
 
@@ -19833,7 +19833,7 @@ EOM
                 if (DEBUG_RECOMBINE) {
                     my $num_compares = $rhash->{_num_compares};
                     my $pair_count   = @ix_list;
-                    print STDERR
+                    print {*STDOUT}
 "Entering optimization phase at $num_compares compares, pair count = $pair_count\n";
                 }
             }
@@ -21600,7 +21600,7 @@ sub break_long_lines {
         }
 
         DEBUG_BREAK_LINES
-          && print STDOUT
+          && print {*STDOUT}
 "BREAK: best is i = $i_lowest strength = $lowest_strength;\nReason>> $Msg\n";
 
         $line_count++;
@@ -22125,7 +22125,7 @@ sub break_lines_inner_loop {
             }
             if ( length($ltok) > 6 ) { $ltok = substr( $ltok, 0, 8 ) }
             if ( length($rtok) > 6 ) { $rtok = substr( $rtok, 0, 8 ) }
-            print STDOUT
+            print {*STDOUT}
 "BREAK: i=$i_test imax=$imax $types_to_go[$i_test] $next_nonblank_type sp=($leading_spaces) lnext= $summed_lengths_to_go[$i_testp2] str=$strength    $ltok $rtok\n";
         };
 
@@ -24532,7 +24532,7 @@ EOM
               ( int $number_of_fields / 2 ) * $pair_width +
               ( $number_of_fields % 2 ) * $max_width;
 
-            print STDOUT
+            print {*STDOUT}
 "SPARSE:cols=$columns commas=$comma_count items:$item_count ids=$identifier_count pairwidth=$pair_width fields=$number_of_fields lines packed: $packed_lines packed_cols=$packed_columns fmtd:$formatted_lines cols /line:$columns_per_line  unused:$unused_columns fmtd:$formatted_columns sparsity=$sparsity allow=$max_allowed_sparsity\n";
 
         };
@@ -25432,7 +25432,7 @@ sub set_nobreaks {
 
         0 && do {
             my ( $a, $b, $c ) = caller();
-            print STDOUT
+            print {*STDOUT}
 "NOBREAK: forced_breakpoint $forced_breakpoint_count from $a $c with i=$i max=$max_index_to_go type=$types_to_go[$i]\n";
         };
 
@@ -26405,7 +26405,7 @@ EOM
                 DEBUG_LP && do {
                     my $tok_beg = $rLL->[$K_begin_line]->[_TOKEN_];
                     my $token   = $tokens_to_go[$ii];
-                    print STDERR <<EOM;
+                    print {*STDOUT} <<EOM;
 DEBUG_LP: Created object at tok=$token type=$type for seqno $align_seqno level=$level ci=$ci_level spaces=$space_count avail=$available_spaces kbeg=$K_begin_line tokbeg=$tok_beg lp=$lp_position_predictor
 EOM
                 };
index 180c4aa128ec739d0cbf09d7b1fd90ef66e4fd17..7565944a9cbee67cc1700f1916195c8eb8d4b756 100644 (file)
@@ -62,7 +62,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index 195cf28e7d7316e1672d4d5b8279e93128ca9f90..c83583a8d78e3eea54f3635e3662e315c95187a5 100644 (file)
@@ -23,7 +23,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index dbaf4555cd600d4aed9ffa1def8b9bc961e23149..b4fc4443b6102ce4ba646d706d04c447061465b2 100644 (file)
@@ -25,7 +25,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index 3cadcff8ec3b2c74878c317e5c668e3003e173fc..05545a0e325d0cc9ec8d2481cc82f20e20954ebd 100644 (file)
@@ -44,7 +44,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index be6b96482cc1869cb31bf5f12142be7f7336b6e7..8470784cc47f0aed71be67d0ac516e8bb20a427b 100644 (file)
@@ -24,7 +24,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
index bbf61d824f7dfb83baa3a5936867a62ba631354d..6ecc5550d1f1079b35f4a05a50f386dcf382035c 100644 (file)
@@ -234,7 +234,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
@@ -2387,7 +2387,7 @@ EOM
                 || $id_scan_state
                 || $context ne $context_simple )
             {
-                print STDERR <<EOM;
+                print {*STDERR} <<EOM;
 scan_simple_identifier differs from scan_identifier:
 simple:  i=$i_simple, tok=$tok_simple, type=$fast_scan_type, ident=$identifier_simple, context='$context_simple
 full:    i=$i, tok=$tok, type=$type, ident=$identifier, context='$context state=$id_scan_state
@@ -2645,7 +2645,7 @@ EOM
                 || ( $i != $i_simple && $i <= $max_token_index )
                 || $number ne $number_simple )
             {
-                print STDERR <<EOM;
+                print {*STDERR} <<EOM;
 scan_number_fast differs from scan_number:
 simple:  i=$i_simple, type=$type_simple, number=$number_simple
 full:  i=$i, type=$type, number=$number
@@ -2724,13 +2724,13 @@ EOM
     my %Z_test_hash;
 
     BEGIN {
-        my @q = qw#
+        my @qZ = qw#
           -> ; } ) ]
           => =~ = == !~ || >= != *= .. && |= .= -= += <= %=
           ^= &&= ||= //= <=>
           #;
-        push @q, ',';
-        @{Z_test_hash}{@q} = (1) x scalar(@q);
+        push @qZ, ',';
+        @{Z_test_hash}{@qZ} = (1) x scalar(@qZ);
     }
 
     sub do_DOLLAR_SIGN {
@@ -2762,7 +2762,7 @@ EOM
 
             # An identifier followed by '->' is not indirect object;
             # fixes b1175, b1176. Fix c257: Likewise for other tokens like
-            # comma, semicolon, closing brace, ...
+            # comma, semicolon, closing brace, and single space.
             my ( $next_nonblank_token, $i_next ) =
               $self->find_next_noncomment_token( $i, $rtokens,
                 $max_token_index );
@@ -5453,7 +5453,7 @@ EOM
                     $rbrace_type->[$brace_depth], $paren_depth,
                     $rparen_type->[$paren_depth],
                 );
-                print STDOUT "TOKENIZE:(@debug_list)\n";
+                print {*STDOUT} "TOKENIZE:(@debug_list)\n";
             };
 
             # We have the next token, $tok.
@@ -5903,7 +5903,7 @@ sub operator_expected {
     my $op_expected = $op_expected_table{$last_nonblank_type};
     if ( defined($op_expected) ) {
         DEBUG_OPERATOR_EXPECTED
-          && print STDOUT
+          && print {*STDOUT}
 "OPERATOR_EXPECTED: Table Lookup; returns $op_expected for last type $last_nonblank_type token $last_nonblank_token\n";
         return $op_expected;
     }
@@ -6117,7 +6117,7 @@ sub operator_expected {
     }
 
     DEBUG_OPERATOR_EXPECTED
-      && print STDOUT
+      && print {*STDOUT}
 "OPERATOR_EXPECTED: returns $op_expected for last type $last_nonblank_type token $last_nonblank_token\n";
 
     return $op_expected;
@@ -7522,7 +7522,7 @@ EOM
     }
 
     DEBUG_NSCAN && do {
-        print STDOUT
+        print {*STDOUT}
           "NSCAN: returns i=$i, tok=$tok, type=$type, state=$id_scan_state\n";
     };
     return ( $i, $tok, $type, $id_scan_state );
@@ -8524,9 +8524,9 @@ EOM
 
         DEBUG_SCAN_ID && do {
             my ( $a, $b, $c ) = caller;
-            print STDOUT
+            print {*STDOUT}
 "SCANID: called from $a $b $c with tok, i, state, identifier =$tok_begin, $i_begin, $id_scan_state_begin, $identifier_begin\n";
-            print STDOUT
+            print {*STDOUT}
 "SCANID: returned with tok, i, state, identifier =$tok, $i, $id_scan_state, $identifier\n";
         };
         return ( $i, $tok, $type, $id_scan_state, $identifier,
@@ -9700,7 +9700,7 @@ sub follow_quoted_string {
     my $quoted_string = EMPTY_STRING;
 
     0 && do {
-        print STDOUT
+        print {*STDOUT}
 "QUOTE entering with quote_pos = $quote_pos i=$i beginning_tok =$beginning_tok\n";
     };
 
@@ -10034,7 +10034,7 @@ sub show_tokens {
 
     foreach my $i ( 0 .. $num - 1 ) {
         my $len = length( $rtokens->[$i] );
-        print STDOUT "$i:$len:$rtoken_map->[$i]:$rtokens->[$i]:\n";
+        print {*STDOUT} "$i:$len:$rtoken_map->[$i]:$rtokens->[$i]:\n";
     }
     return;
 } ## end sub show_tokens
index 0c3e7cb94539bbb69f866df6c232f426183d2bf0..080099ad7282fdf0827a01846b4162337988be98 100644 (file)
@@ -68,7 +68,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'
@@ -205,7 +205,7 @@ BEGIN {
     use constant DEBUG_TABS => 0;
 
     my $debug_warning = sub {
-        print STDOUT "VALIGN_DEBUGGING with key $_[0]\n";
+        print {*STDOUT} "VALIGN_DEBUGGING with key $_[0]\n";
         return;
     };
 
@@ -679,7 +679,7 @@ sub valign_input {
 
     DEBUG_VALIGN && do {
         my $nlines = $self->group_line_count();
-        print STDOUT
+        print {*STDOUT}
 "Entering valign_input: lines=$nlines new #fields= $jmax, leading_count=$leading_space_count, level=$level, group_level=$group_level, level_end=$level_end\n";
     };
 
@@ -954,11 +954,11 @@ sub valign_input {
     # Some old debugging stuff
     # --------------------------------------------------------------------
     DEBUG_VALIGN && do {
-        print STDOUT "exiting valign_input fields:";
+        print {*STDOUT} "exiting valign_input fields:";
         dump_array( @{$rfields} );
-        print STDOUT "exiting valign_input tokens:";
+        print {*STDOUT} "exiting valign_input tokens:";
         dump_array( @{$rtokens} );
-        print STDOUT "exiting valign_input patterns:";
+        print {*STDOUT} "exiting valign_input patterns:";
         dump_array( @{$rpatterns} );
     };
 
@@ -1127,12 +1127,12 @@ sub fix_terminal_ternary {
 
     EXPLAIN_TERNARY && do {
         local $LIST_SEPARATOR = '><';
-        print STDOUT "CURRENT FIELDS=<@{$rfields_old}>\n";
-        print STDOUT "CURRENT TOKENS=<@{$rtokens_old}>\n";
-        print STDOUT "CURRENT PATTERNS=<@{$rpatterns_old}>\n";
-        print STDOUT "UNMODIFIED FIELDS=<@{$rfields}>\n";
-        print STDOUT "UNMODIFIED TOKENS=<@{$rtokens}>\n";
-        print STDOUT "UNMODIFIED PATTERNS=<@{$rpatterns}>\n";
+        print {*STDOUT} "CURRENT FIELDS=<@{$rfields_old}>\n";
+        print {*STDOUT} "CURRENT TOKENS=<@{$rtokens_old}>\n";
+        print {*STDOUT} "CURRENT PATTERNS=<@{$rpatterns_old}>\n";
+        print {*STDOUT} "UNMODIFIED FIELDS=<@{$rfields}>\n";
+        print {*STDOUT} "UNMODIFIED TOKENS=<@{$rtokens}>\n";
+        print {*STDOUT} "UNMODIFIED PATTERNS=<@{$rpatterns}>\n";
     };
 
     # handle cases of leading colon on this line
@@ -1216,9 +1216,9 @@ sub fix_terminal_ternary {
 
     EXPLAIN_TERNARY && do {
         local $LIST_SEPARATOR = '><';
-        print STDOUT "MODIFIED TOKENS=<@tokens>\n";
-        print STDOUT "MODIFIED PATTERNS=<@patterns>\n";
-        print STDOUT "MODIFIED FIELDS=<@fields>\n";
+        print {*STDOUT} "MODIFIED TOKENS=<@tokens>\n";
+        print {*STDOUT} "MODIFIED PATTERNS=<@patterns>\n";
+        print {*STDOUT} "MODIFIED FIELDS=<@fields>\n";
     };
 
     # all ok .. update the arrays
@@ -1541,7 +1541,7 @@ sub dump_array {
 
     # debug routine to dump array contents
     local $LIST_SEPARATOR = ')(';
-    print STDOUT "(@_)\n";
+    print {*STDOUT} "(@_)\n";
     return;
 } ## end sub dump_array
 
@@ -1654,7 +1654,7 @@ sub _flush_group_lines {
     0 && do {
         my ( $a, $b, $c ) = caller();
         my $nlines = @{$rgroup_lines};
-        print STDOUT
+        print {*STDOUT}
 "APPEND0: _flush_group_lines called from $a $b $c lines=$nlines, type=$group_type \n";
     };
 
@@ -3409,7 +3409,7 @@ sub compare_patterns {
 
     EXPLAIN_COMPARE_PATTERNS
       && $return_code
-      && print STDERR "no match because $GoToMsg\n";
+      && print {*STDOUT} "no match because $GoToMsg\n";
 
     return ( $return_code, \$GoToMsg );
 
index d3d7a3d64c6d74405368da37ef0252ca8b573e74..678b8908847250a4ec2aacf695b6d1d4ce22efb3 100644 (file)
@@ -27,7 +27,7 @@ sub AUTOLOAD {
     return if ( $AUTOLOAD =~ /\bDESTROY$/ );
     my ( $pkg, $fname, $lno ) = caller();
     my $my_package = __PACKAGE__;
-    print STDERR <<EOM;
+    print {*STDERR} <<EOM;
 ======================================================================
 Error detected in package '$my_package', version $VERSION
 Received unexpected AUTOLOAD call for sub '$AUTOLOAD'