]> git.donarmstrong.com Git - perltidy.git/commitdiff
define constants EMPTY_STRING and SPACE
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 13 May 2022 04:19:58 +0000 (21:19 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 13 May 2022 04:19:58 +0000 (21:19 -0700)
lib/Perl/Tidy.pm
lib/Perl/Tidy/Debugger.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/Logger.pm
lib/Perl/Tidy/Tokenizer.pm
lib/Perl/Tidy/VerticalAligner.pm

index 2b1dca4eeabd1f37d3ff713b4b3a318411c2fd56..7690597938d5b78d918f2f09c99947f505312a89 100644 (file)
@@ -80,8 +80,10 @@ use Perl::Tidy::Tokenizer;
 use Perl::Tidy::VerticalAligner;
 local $OUTPUT_AUTOFLUSH = 1;
 
-# this can be turned on for extra checking during development
-use constant DEVEL_MODE => 0;
+# DEVEL_MODE can be turned on for extra checking during development
+use constant DEVEL_MODE   => 0;
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
 
 use vars qw{
   $VERSION
@@ -487,17 +489,17 @@ sub perltidy {
     my $rstatus = {
 
         file_count         => 0,
-        opt_format         => "",
-        opt_encoding       => "",
-        opt_encode_output  => "",
-        opt_max_iterations => "",
+        opt_format         => EMPTY_STRING,
+        opt_encoding       => EMPTY_STRING,
+        opt_encode_output  => EMPTY_STRING,
+        opt_max_iterations => EMPTY_STRING,
 
-        input_name        => "",
-        output_name       => "",
+        input_name        => EMPTY_STRING,
+        output_name       => EMPTY_STRING,
         char_mode_source  => 0,
         char_mode_used    => 0,
-        input_decoded_as  => "",
-        output_encoded_as => "",
+        input_decoded_as  => EMPTY_STRING,
+        output_encoded_as => EMPTY_STRING,
         gcs_used          => 0,
         iteration_count   => 0,
         converged         => 0,
@@ -633,7 +635,7 @@ EOM
         }
     }
     else {
-        $dump_options_type = "";
+        $dump_options_type = EMPTY_STRING;
     }
 
     if ($user_formatter) {
@@ -678,9 +680,9 @@ EOM
     }
 
     my $rpending_complaint;
-    ${$rpending_complaint} = "";
+    ${$rpending_complaint} = EMPTY_STRING;
     my $rpending_logfile_message;
-    ${$rpending_logfile_message} = "";
+    ${$rpending_logfile_message} = EMPTY_STRING;
 
     my ( $is_Windows, $Windows_type ) = look_for_Windows($rpending_complaint);
 
@@ -722,7 +724,7 @@ EOM
         $quit_now = 1;
         foreach my $op ( @{$roption_string} ) {
             my $opt  = $op;
-            my $flag = "";
+            my $flag = EMPTY_STRING;
 
             # Examples:
             #  some-option=s
@@ -782,7 +784,7 @@ EOM
     my %default_file_extension = (
         tidy => 'tdy',
         html => 'html',
-        user => '',
+        user => EMPTY_STRING,
     );
 
     $rstatus->{'opt_format'}         = $rOpts->{'format'};
@@ -792,7 +794,7 @@ EOM
 
     # be sure we have a valid output format
     unless ( exists $default_file_extension{ $rOpts->{'format'} } ) {
-        my $formats = join ' ',
+        my $formats = join SPACE,
           sort map { "'" . $_ . "'" } keys %default_file_extension;
         my $fmt = $rOpts->{'format'};
         Die("-format='$fmt' but must be one of: $formats\n");
@@ -1101,7 +1103,7 @@ EOM
         my %saw_md5;
         my $digest_input = 0;
 
-        my $buf = '';
+        my $buf = EMPTY_STRING;
         while ( my $line = $source_object->get_line() ) {
             $buf .= $line;
         }
@@ -1110,10 +1112,10 @@ EOM
           !$rOpts->{'add-terminal-newline'} && substr( $buf, -1, 1 ) !~ /\n/;
 
         # Decode the input stream if necessary or requested
-        my $encoding_in              = "";
+        my $encoding_in              = EMPTY_STRING;
         my $rOpts_character_encoding = $rOpts->{'character-encoding'};
         my $encoding_log_message;
-        my $decoded_input_as = "";
+        my $decoded_input_as = EMPTY_STRING;
         $rstatus->{'char_mode_source'} = 0;
 
         # Case 1: If Perl is already in a character-oriented mode for this
@@ -1155,7 +1157,7 @@ EOM
             if ( ref($decoder) ) {
                 $encoding_in = $decoder->name;
                 if ( $encoding_in ne 'UTF-8' && $encoding_in ne 'utf8' ) {
-                    $encoding_in = "";
+                    $encoding_in = EMPTY_STRING;
                     $buf         = $buf_in;
                     $encoding_log_message .= <<EOM;
 Guessed encoding '$encoding_in' is not utf8; no encoding will be used
@@ -1175,7 +1177,7 @@ EOM
                         Warn(
 "file: $input_file: bad guess to decode source as $encoding_in\n"
                         );
-                        $encoding_in = "";
+                        $encoding_in = EMPTY_STRING;
                         $buf         = $buf_in;
                     }
                     else {
@@ -1222,7 +1224,7 @@ EOM
         # read and write it as encoded data, and we will normalize these
         # operations with utf8.  If we have not decoded the data, then
         # we must not treat it as encoded data.
-        my $is_encoded_data = $encoding_in ? 'utf8' : "";
+        my $is_encoded_data = $encoding_in ? 'utf8' : EMPTY_STRING;
 
         $rstatus->{'input_name'}       = $display_name;
         $rstatus->{'opt_encoding'}     = $rOpts_character_encoding;
@@ -1298,7 +1300,7 @@ EOM
         # prepare the output stream
         #---------------------------------------------------------------
         my $output_file = undef;
-        my $output_name = "";
+        my $output_name = EMPTY_STRING;
         my $actual_output_extension;
 
         if ( $rOpts->{'outfile'} ) {
@@ -1829,7 +1831,7 @@ EOM
 
             # -eos flag set: If perltidy decodes a string, regardless of
             # source, it encodes before returning.
-            $rstatus->{'output_encoded_as'} = '';
+            $rstatus->{'output_encoded_as'} = EMPTY_STRING;
 
             if ($encode_destination_buffer) {
                 my $encoded_buffer;
@@ -2093,7 +2095,7 @@ sub line_diff {
     # have same common characters so non-null characters indicate character
     # differences.
     my ( $s1, $s2 ) = @_;
-    my $diff_marker = "";
+    my $diff_marker = EMPTY_STRING;
     my $pos         = -1;
     my $pos1        = $pos;
     if ( defined($s1) && defined($s2) ) {
@@ -2105,7 +2107,7 @@ sub line_diff {
             my $pos_last = $pos;
             $pos = $LAST_MATCH_START[0];
             if ( $count == 1 ) { $pos1 = $pos; }
-            $diff_marker .= ' ' x ( $pos - $pos_last - 1 ) . '^';
+            $diff_marker .= SPACE x ( $pos - $pos_last - 1 ) . '^';
 
             # we could continue to mark all differences, but there is no point
             last;
@@ -2129,9 +2131,9 @@ sub compare_string_buffers {
     my ( $fhi, $fnamei ) = streamhandle( \$bufi, 'r', $is_encoded_data );
     my ( $fho, $fnameo ) = streamhandle( \$bufo, 'r', $is_encoded_data );
     return $msg unless ( $fho && $fhi );    # for safety, shouldn't happen
-    my ( $linei,              $lineo );
-    my ( $counti,             $counto )              = ( 0,  0 );
-    my ( $last_nonblank_line, $last_nonblank_count ) = ( "", 0 );
+    my ( $linei,  $lineo );
+    my ( $counti, $counto )                          = ( 0, 0 );
+    my ( $last_nonblank_line, $last_nonblank_count ) = ( EMPTY_STRING, 0 );
     my $truncate = sub {
         my ( $str, $lenmax ) = @_;
         if ( length($str) > $lenmax ) {
@@ -2160,7 +2162,7 @@ sub compare_string_buffers {
         my ( $line_diff, $pos1 ) = line_diff( $linei, $lineo );
         my $reason = "Files first differ at character $pos1 of line $counti";
 
-        my ( $leading_ws_i, $leading_ws_o ) = ( "", "" );
+        my ( $leading_ws_i, $leading_ws_o ) = ( EMPTY_STRING, EMPTY_STRING );
         if ( $linei =~ /^(\s+)/ ) { $leading_ws_i = $1; }
         if ( $lineo =~ /^(\s+)/ ) { $leading_ws_o = $1; }
         if ( $leading_ws_i ne $leading_ws_o ) {
@@ -2170,7 +2172,8 @@ sub compare_string_buffers {
             }
         }
         else {
-            my ( $trailing_ws_i, $trailing_ws_o ) = ( "", "" );
+            my ( $trailing_ws_i, $trailing_ws_o ) =
+              ( EMPTY_STRING, EMPTY_STRING );
             if ( $linei =~ /(\s+)$/ ) { $trailing_ws_i = $1; }
             if ( $lineo =~ /(\s+)$/ ) { $trailing_ws_o = $1; }
             if ( $trailing_ws_i ne $trailing_ws_o ) {
@@ -2182,9 +2185,9 @@ sub compare_string_buffers {
         # limit string display length
         if ( $pos1 > 60 ) {
             my $drop = $pos1 - 40;
-            $linei     = "..." . substr( $linei,     $drop );
-            $lineo     = "..." . substr( $lineo,     $drop );
-            $line_diff = "   " . substr( $line_diff, $drop );
+            $linei     = "..." . substr( $linei, $drop );
+            $lineo     = "..." . substr( $lineo, $drop );
+            $line_diff = SPACE x 3 . substr( $line_diff, $drop );
         }
         $linei              = $truncate->( $linei,              72 );
         $lineo              = $truncate->( $lineo,              72 );
@@ -2196,7 +2199,7 @@ sub compare_string_buffers {
  $last_nonblank_count:$last_nonblank_line
 EOM
         }
-        $line_diff = ' ' x ( 2 + length($counto) ) . $line_diff;
+        $line_diff = SPACE x ( 2 + length($counto) ) . $line_diff;
         $msg .= <<EOM;
 <$counti:$linei
 >$counto:$lineo
@@ -2305,7 +2308,7 @@ sub write_logfile_header {
     if ($Windows_type) {
         $logger_object->write_logfile_entry("Windows type is $Windows_type\n");
     }
-    my $options_string = join( ' ', @{$rraw_options} );
+    my $options_string = join( SPACE, @{$rraw_options} );
 
     if ($config_file) {
         $logger_object->write_logfile_entry(
@@ -2726,11 +2729,11 @@ sub generate_options {
     $add_option->( 'dump-want-left-space',    'dwls', '!' );
     $add_option->( 'dump-want-right-space',   'dwrs', '!' );
     $add_option->( 'fuzzy-line-length',       'fll',  '!' );
-    $add_option->( 'help',                    'h',    '' );
+    $add_option->( 'help',                    'h',    EMPTY_STRING );
     $add_option->( 'short-concatenation-item-length', 'scl',   '=i' );
     $add_option->( 'show-options',                    'opt',   '!' );
     $add_option->( 'timestamp',                       'ts',    '!' );
-    $add_option->( 'version',                         'v',     '' );
+    $add_option->( 'version',                         'v',     EMPTY_STRING );
     $add_option->( 'memoize',                         'mem',   '!' );
     $add_option->( 'file-size-order',                 'fso',   '!' );
     $add_option->( 'maximum-file-size-mb',            'maxfs', '=i' );
@@ -3246,7 +3249,7 @@ sub _process_command_line {
 
     my $word;
     my @raw_options        = ();
-    my $config_file        = "";
+    my $config_file        = EMPTY_STRING;
     my $saw_ignore_profile = 0;
     my $saw_dump_profile   = 0;
 
@@ -3290,7 +3293,7 @@ sub _process_command_line {
             }
             unless ( -e $config_file ) {
                 Warn("cannot find file given with -pro=$config_file: $ERRNO\n");
-                $config_file = "";
+                $config_file = EMPTY_STRING;
             }
         }
         elsif ( $i =~ /^-(pro|profile)=?$/ ) {
@@ -3351,7 +3354,7 @@ EOM
 
         # look for a config file if we don't have one yet
         my $rconfig_file_chatter;
-        ${$rconfig_file_chatter} = "";
+        ${$rconfig_file_chatter} = EMPTY_STRING;
         $config_file =
           find_config_file( $is_Windows, $Windows_type, $rconfig_file_chatter,
             $rpending_complaint )
@@ -3469,7 +3472,7 @@ sub make_grep_alias_string {
 
     # Defaults: list operators in List::Util
     # Possible future additions:  pairfirst pairgrep pairmap
-    my $default_string = join ' ', qw(
+    my $default_string = join SPACE, qw(
       all
       any
       first
@@ -3491,11 +3494,11 @@ sub make_grep_alias_string {
     }
 
     # The special option -gaxl='*' removes all defaults
-    if ( $is_excluded_word{'*'} ) { $default_string = "" }
+    if ( $is_excluded_word{'*'} ) { $default_string = EMPTY_STRING }
 
     # combine the defaults and any input list
     my $input_string = $rOpts->{'grep-alias-list'};
-    if ($input_string) { $input_string .= " " . $default_string }
+    if ($input_string) { $input_string .= SPACE . $default_string }
     else               { $input_string = $default_string }
 
     # Now make the final list of unique grep alias words
@@ -3519,7 +3522,7 @@ sub make_grep_alias_string {
             }
         }
     }
-    my $joined_words = join ' ', @filtered_word_list;
+    my $joined_words = join SPACE, @filtered_word_list;
     $rOpts->{'grep-alias-list'} = $joined_words;
     return;
 }
@@ -3711,7 +3714,7 @@ EOM
                 }
             }
         }
-        $rOpts->{'sub-alias-list'} = join ' ', @filtered_word_list;
+        $rOpts->{'sub-alias-list'} = join SPACE, @filtered_word_list;
     }
 
     make_grep_alias_string($rOpts);
@@ -3811,7 +3814,7 @@ sub expand_command_abbreviations {
                 # to allow abbreviations with arguments such as '-vt=1'
                 if ( $rexpansion->{ $abr . $flags } ) {
                     $abr   = $abr . $flags;
-                    $flags = "";
+                    $flags = EMPTY_STRING;
                 }
 
                 # if we see this dash item in the expansion hash..
@@ -3926,7 +3929,7 @@ sub check_vms_filename {
     $base .= '.' unless $base =~ /(?:^|[^^])\./;
 
     # if we don't already have an extension then we just append the extension
-    my $separator = ( $base =~ /\.$/ ) ? "" : "_";
+    my $separator = ( $base =~ /\.$/ ) ? EMPTY_STRING : "_";
     return ( $path . $base, $separator );
 }
 
@@ -3942,7 +3945,7 @@ sub Win_OS_Type {
     # We need to know this to decide where to look for config files
 
     my $rpending_complaint = shift;
-    my $os                 = "";
+    my $os                 = EMPTY_STRING;
     return $os unless $OSNAME =~ /win32|dos/i;    # is it a MS box?
 
     # Systems built from Perl source may not have Win32.pm
@@ -3980,7 +3983,7 @@ sub Win_OS_Type {
     # If $os is undefined, the above code is out of date.  Suggested updates
     # are welcome.
     unless ( defined $os ) {
-        $os = "";
+        $os = EMPTY_STRING;
 
         # Deactivated this message 20180322 because it was needlessly
         # causing some test scripts to fail.  Need help from someone
@@ -4177,8 +4180,8 @@ sub Win_Config_Locs {
 
     return unless $os;
 
-    my $system   = "";
-    my $allusers = "";
+    my $system   = EMPTY_STRING;
+    my $allusers = EMPTY_STRING;
 
     if ( $os =~ /9[58]|Me/ ) {
         $system = "C:/Windows";
@@ -4221,7 +4224,7 @@ sub read_config_file {
     my @config_list = ();
 
     # file is bad if non-empty $death_message is returned
-    my $death_message = "";
+    my $death_message = EMPTY_STRING;
 
     my $name = undef;
     my $line_no;
@@ -4321,11 +4324,11 @@ sub strip_comment {
 
     # Strip any comment from a command line
     my ( $instr, $config_file, $line_no ) = @_;
-    my $msg = "";
+    my $msg = EMPTY_STRING;
 
     # check for full-line comment
     if ( $instr =~ /^\s*#/ ) {
-        return ( "", $msg );
+        return ( EMPTY_STRING, $msg );
     }
 
     # nothing to do if no comments
@@ -4346,14 +4349,14 @@ sub strip_comment {
     }
 
     # handle comments and quotes
-    my $outstr     = "";
-    my $quote_char = "";
+    my $outstr     = EMPTY_STRING;
+    my $quote_char = EMPTY_STRING;
     while (1) {
 
         # looking for ending quote character
         if ($quote_char) {
             if ( $instr =~ /\G($quote_char)/gc ) {
-                $quote_char = "";
+                $quote_char = EMPTY_STRING;
                 $outstr .= $1;
             }
             elsif ( $instr =~ /\G(.)/gc ) {
@@ -4407,20 +4410,20 @@ sub parse_args {
 
     my ($body)     = @_;
     my @body_parts = ();
-    my $quote_char = "";
-    my $part       = "";
-    my $msg        = "";
+    my $quote_char = EMPTY_STRING;
+    my $part       = EMPTY_STRING;
+    my $msg        = EMPTY_STRING;
 
     # Check for external call with undefined $body - added to fix
     # github issue Perl-Tidy-Sweetened issue #23
-    if ( !defined($body) ) { $body = "" }
+    if ( !defined($body) ) { $body = EMPTY_STRING }
 
     while (1) {
 
         # looking for ending quote character
         if ($quote_char) {
             if ( $body =~ /\G($quote_char)/gc ) {
-                $quote_char = "";
+                $quote_char = EMPTY_STRING;
             }
             elsif ( $body =~ /\G(.)/gc ) {
                 $part .= $1;
@@ -4444,7 +4447,7 @@ EOM
             }
             elsif ( $body =~ /\G(\s+)/gc ) {
                 if ( length($part) ) { push @body_parts, $part; }
-                $part = "";
+                $part = EMPTY_STRING;
             }
             elsif ( $body =~ /\G(.)/gc ) {
                 $part .= $1;
@@ -4499,7 +4502,7 @@ sub readable_options {
     $readable_options .=
       "# See utility 'perltidyrc_dump.pl' for nicer formatting.\n";
     foreach my $opt ( @{$roption_string} ) {
-        my $flag = "";
+        my $flag = EMPTY_STRING;
         if ( $opt =~ /(.*)(!|=.*)$/ ) {
             $opt  = $1;
             $flag = $2;
@@ -4512,7 +4515,7 @@ sub readable_options {
         my $flag   = $rGetopt_flags->{$key};
         my $value  = $rOpts->{$key};
         my $prefix = '--';
-        my $suffix = "";
+        my $suffix = EMPTY_STRING;
         if ($flag) {
             if ( $flag =~ /^=/ ) {
                 if ( $value !~ /^\d+$/ ) { $value = '"' . $value . '"' }
index 3e3e76a68e6fba638ad045bac8a06d2e696cad03..40cfd348aa704ff8676581cfbcc6225fde402352 100644 (file)
@@ -10,6 +10,9 @@ use warnings;
 use English qw( -no_match_vars );
 our $VERSION = '20220217.04';
 
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
+
 sub new {
 
     my ( $class, $filename, $is_encoded_data ) = @_;
@@ -76,7 +79,7 @@ sub write_debug_entry {
     my $reconstructed_original = "$input_line_number: ";
     my $block_str              = "$input_line_number: ";
 
-    my $pattern   = "";
+    my $pattern   = EMPTY_STRING;
     my @next_char = ( '"', '"' );
     my $i_next    = 0;
     unless ( $self->{_debug_file_opened} ) { $self->really_open_debug_file() }
@@ -99,7 +102,7 @@ sub write_debug_entry {
         # be sure there are no blank tokens (shouldn't happen)
         # This can only happen if a programming error has been made
         # because all valid tokens are non-blank
-        if ( $type_str eq ' ' ) {
+        if ( $type_str eq SPACE ) {
             $fh->print("BLANK TOKEN on the next line\n");
             $type_str = $next_char[$i_next];
             $i_next   = 1 - $i_next;
index fcddc5a5b0a68b69f91cdf53d8ad5a6da3d3c0a6..fe40873e490b26660d9f2effbc73f0d51995641e 100644 (file)
@@ -23,6 +23,8 @@ use warnings;
 use English qw( -no_match_vars );
 our $VERSION = '20220217.04';
 
+use constant EMPTY_STRING => q{};
+
 sub AUTOLOAD {
 
     # Catch any undefined sub calls so that we are sure to get
@@ -54,8 +56,8 @@ sub new {
     my $class = shift;
     return bless {
         _write_diagnostics_count => 0,
-        _last_diagnostic_file    => "",
-        _input_file              => "",
+        _last_diagnostic_file    => EMPTY_STRING,
+        _input_file              => EMPTY_STRING,
         _fh                      => undef,
     }, $class;
 }
index 5f2c871c24f544b8aedaf246609dece869ba3375..9e497f62fd5aec4619b9ca9d083ee9d1ac63e6f0 100644 (file)
@@ -9,7 +9,8 @@ use strict;
 use warnings;
 our $VERSION = '20220217.04';
 
-use constant DEVEL_MODE => 0;
+use constant DEVEL_MODE   => 0;
+use constant EMPTY_STRING => q{};
 
 sub AUTOLOAD {
 
@@ -37,10 +38,10 @@ sub DESTROY {
     # required to avoid call to AUTOLOAD in some versions of perl
 }
 
-my $input_stream_name = "";
+my $input_stream_name = EMPTY_STRING;
 
 # Maximum number of little messages; probably need not be changed.
-my $MAX_NAG_MESSAGES = 6;
+use constant MAX_NAG_MESSAGES => 6;
 
 BEGIN {
 
@@ -142,11 +143,11 @@ sub new {
     $self->[_max_output_line_length_at_]   = 0;
     $self->[_rK_checklist_]                = [];
     $self->[_K_arrival_order_matches_]     = 0;
-    $self->[_K_sequence_error_msg_]        = "";
+    $self->[_K_sequence_error_msg_]        = EMPTY_STRING;
     $self->[_K_last_arrival_]              = -1;
 
     # save input stream name for local error messages
-    $input_stream_name = "";
+    $input_stream_name = EMPTY_STRING;
     if ($logger_object) {
         $input_stream_name = $logger_object->get_input_stream_name();
     }
@@ -168,7 +169,7 @@ sub setup_convergence_test {
         $self->[_rK_checklist_] = \@list;
     }
     $self->[_K_arrival_order_matches_] = 1;
-    $self->[_K_sequence_error_msg_]    = "";
+    $self->[_K_sequence_error_msg_]    = EMPTY_STRING;
     $self->[_K_last_arrival_]          = -1;
     return;
 }
@@ -256,6 +257,8 @@ sub write_blank_code_line {
     return;
 }
 
+use constant MAX_PRINTED_CHARS => 80;
+
 sub write_code_line {
     my ( $self, $str, $K ) = @_;
 
@@ -290,8 +293,8 @@ sub write_code_line {
             my $K_prev = $self->[_K_last_arrival_];
             if ( $K < $K_prev ) {
                 chomp $str;
-                if ( length($str) > 80 ) {
-                    $str = substr( $str, 0, 80 ) . "...";
+                if ( length($str) > MAX_PRINTED_CHARS ) {
+                    $str = substr( $str, 0, MAX_PRINTED_CHARS ) . "...";
                 }
 
                 my $msg = <<EOM;
@@ -355,7 +358,7 @@ sub write_line {
             $self->[_max_line_length_error_at_] = $output_line_number - 1;
         }
 
-        if ( $self->[_line_length_error_count_] < $MAX_NAG_MESSAGES ) {
+        if ( $self->[_line_length_error_count_] < MAX_NAG_MESSAGES ) {
             $self->write_logfile_entry(
                 "Line length exceeded by $exceed characters\n");
         }
@@ -380,12 +383,12 @@ sub report_line_length_errors {
     }
     else {
 
-        my $word = ( $line_length_error_count > 1 ) ? "s" : "";
+        my $word = ( $line_length_error_count > 1 ) ? "s" : EMPTY_STRING;
         $self->write_logfile_entry(
 "$line_length_error_count output line$word exceeded $rOpts->{'maximum-line-length'} characters:\n"
         );
 
-        $word = ( $line_length_error_count > 1 ) ? "First" : "";
+        $word = ( $line_length_error_count > 1 ) ? "First" : EMPTY_STRING;
         my $first_line_length_error    = $self->[_first_line_length_error_];
         my $first_line_length_error_at = $self->[_first_line_length_error_at_];
         $self->write_logfile_entry(
index 4cae92a4ba782f6703de1575e0abb2de5f2c5c1d..39f75cc129335d2623fd1586a82f8e533fe6bde6 100644 (file)
@@ -43,8 +43,10 @@ package Perl::Tidy::Formatter;
 use strict;
 use warnings;
 
-# This flag gets switched on during automated testing for extra checking
-use constant DEVEL_MODE => 0;
+# DEVEL_MODE gets switched on during automated testing for extra checking
+use constant DEVEL_MODE   => 0;
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
 
 { #<<< A non-indenting brace to contain all lexical variables
 
@@ -717,7 +719,7 @@ sub new {
         diagnostics_object => undef,
         logger_object      => undef,
         length_function    => sub { return length( $_[0] ) },
-        is_encoded_data    => "",
+        is_encoded_data    => EMPTY_STRING,
         fh_tee             => undef,
     );
     my %args = ( %defaults, @args );
@@ -961,7 +963,7 @@ sub check_rLL {
         # by making calls to this routine at different locations in
         # sub 'finish_formatting'.
         $Klimit = 'undef' if ( !defined($Klimit) );
-        $msg    = "" unless $msg;
+        $msg    = EMPTY_STRING unless $msg;
         Fault("$msg ERROR: rLL has num=$num but Klimit='$Klimit'\n");
     }
     return;
@@ -1100,7 +1102,7 @@ sub check_token_array {
     }
 
     sub get_input_stream_name {
-        my $input_stream_name = "";
+        my $input_stream_name = EMPTY_STRING;
         if ($logger_object) {
             $input_stream_name = $logger_object->get_input_stream_name();
         }
@@ -1502,6 +1504,8 @@ EOM
     }
 
     # Coordinate ?/: breaks, which must be similar
+    # The small strength 0.01 which is added is 1% of the strength of one
+    # indentation level and seems to work okay.
     if ( !$want_break_before{':'} ) {
         $want_break_before{'?'}   = $want_break_before{':'};
         $right_bond_strength{'?'} = $right_bond_strength{':'} + 0.01;
@@ -1613,12 +1617,12 @@ EOM
     $right_bond_strength{'{'} = WEAK;
     $left_bond_strength{'{'}  = VERY_STRONG;
 
-    # make -l=0  equal to -l=infinite
+    # make -l=0 equal to -l=infinite
     if ( !$rOpts->{'maximum-line-length'} ) {
         $rOpts->{'maximum-line-length'} = 1_000_000;
     }
 
-    # make -lbl=0  equal to -lbl=infinite
+    # make -lbl=0 equal to -lbl=infinite
     if ( !$rOpts->{'long-block-line-count'} ) {
         $rOpts->{'long-block-line-count'} = 1_000_000;
     }
@@ -1654,7 +1658,7 @@ EOM
         else {
             $ole = lc $ole;
             unless ( $rOpts->{'output-line-ending'} = $endings{$ole} ) {
-                my $str = join " ", keys %endings;
+                my $str = join SPACE, keys %endings;
                 Die(<<EOM);
 Unrecognized line ending '$ole'; expecting one of: $str
 EOM
@@ -1698,11 +1702,11 @@ EOM
             push @conflicts, '--break-at-old-semicolon-breakpoints (-bos)';
         }
         if ( $rOpts->{'keep-old-breakpoints-before'} ) {
-            $rOpts->{'keep-old-breakpoints-before'} = "";
+            $rOpts->{'keep-old-breakpoints-before'} = EMPTY_STRING;
             push @conflicts, '--keep-old-breakpoints-before (-kbb)';
         }
         if ( $rOpts->{'keep-old-breakpoints-after'} ) {
-            $rOpts->{'keep-old-breakpoints-after'} = "";
+            $rOpts->{'keep-old-breakpoints-after'} = EMPTY_STRING;
             push @conflicts, '--keep-old-breakpoints-after (-kba)';
         }
 
@@ -1879,10 +1883,10 @@ EOM
     # level only.  If a line has continuation indentation, then that space must
     # be subtracted from the table value.  This table is used for preliminary
     # estimates in welding, extended_ci, BBX, and marking short blocks.
-    my $level_max = 1000;
+    use constant LEVEL_TABLE_MAX => 1000;
 
     # The basic scheme:
-    foreach my $level ( 0 .. $level_max ) {
+    foreach my $level ( 0 .. LEVEL_TABLE_MAX ) {
         my $indent = $level * $rOpts_indent_columns;
         $maximum_line_length_at_level[$level] = $rOpts_maximum_line_length;
         $maximum_text_length_at_level[$level] =
@@ -1893,7 +1897,7 @@ EOM
     $rOpts_whitespace_cycle = $rOpts->{'whitespace-cycle'};
     if ($rOpts_whitespace_cycle) {
         if ( $rOpts_whitespace_cycle > 0 ) {
-            foreach my $level ( 0 .. $level_max ) {
+            foreach my $level ( 0 .. LEVEL_TABLE_MAX ) {
                 my $level_mod = $level % $rOpts_whitespace_cycle;
                 my $indent    = $level_mod * $rOpts_indent_columns;
                 $maximum_text_length_at_level[$level] =
@@ -1908,7 +1912,7 @@ EOM
     # Correct the tables if the -vmll flag is used.  These values override the
     # previous values.
     if ($rOpts_variable_maximum_line_length) {
-        foreach my $level ( 0 .. $level_max ) {
+        foreach my $level ( 0 .. LEVEL_TABLE_MAX ) {
             $maximum_text_length_at_level[$level] = $rOpts_maximum_line_length;
             $maximum_line_length_at_level[$level] =
               $rOpts_maximum_line_length + $level * $rOpts_indent_columns;
@@ -1921,7 +1925,7 @@ EOM
     # formatting features.
     # Put a reasonable upper limit on stress level (say 100) in case the
     # whitespace-cycle variable is used.
-    my $stress_level_limit = min( 100, $level_max );
+    my $stress_level_limit = min( 100, LEVEL_TABLE_MAX );
 
     # Find stress_level_alpha, targeted at very short maximum line lengths.
     $stress_level_alpha = $stress_level_limit + 1;
@@ -2273,7 +2277,7 @@ EOM
             }
         }
         if ($all_off) {
-            $rOpts->{'line-up-parentheses'} = "";
+            $rOpts->{'line-up-parentheses'} = EMPTY_STRING;
         }
     }
 
@@ -2289,7 +2293,7 @@ sub initialize_keep_old_breakpoints {
     my %flags = ();
     my @list  = split_words($str);
     if ( DEBUG_KB && @list ) {
-        local $LIST_SEPARATOR = ' ';
+        local $LIST_SEPARATOR = SPACE;
         print <<EOM;
 DEBUG_KB entering for '$short_name' with str=$str\n";
 list is: @list;
@@ -2314,7 +2318,7 @@ EOM
 
     if (@unknown_types) {
         my $num = @unknown_types;
-        local $LIST_SEPARATOR = ' ';
+        local $LIST_SEPARATOR = SPACE;
         Warn(<<EOM);
 $num unrecognized token types were input with --$short_name :
 @unknown_types
@@ -2385,7 +2389,7 @@ EOM
 
     if ( DEBUG_KB && @list ) {
         my @tmp = %flags;
-        local $LIST_SEPARATOR = ' ';
+        local $LIST_SEPARATOR = SPACE;
         print <<EOM;
 
 DEBUG_KB -$short_name flag: $str
@@ -2586,18 +2590,18 @@ sub set_whitespace_flags {
     my $rtokh_last      = $rLL->[0];
     my $rtokh_last_last = $rtokh_last;
 
-    my $last_type  = '';
-    my $last_token = '';
+    my $last_type  = EMPTY_STRING;
+    my $last_token = EMPTY_STRING;
 
     my $j_tight_closing_paren = -1;
 
     $rtokh = [ @{ $rLL->[0] } ];
-    $token = ' ';
+    $token = SPACE;
     $type  = 'b';
 
     $rtokh->[_TOKEN_]         = $token;
     $rtokh->[_TYPE_]          = $type;
-    $rtokh->[_TYPE_SEQUENCE_] = '';
+    $rtokh->[_TYPE_SEQUENCE_] = EMPTY_STRING;
     $rtokh->[_LINE_INDEX_]    = 0;
 
     # This is some logic moved to a sub to avoid deep nesting of if stmts
@@ -3109,7 +3113,7 @@ sub set_whitespace_flags {
 
         if (DEBUG_WHITE) {
             my $str = substr( $last_token, 0, 15 );
-            $str .= ' ' x ( 16 - length($str) );
+            $str .= SPACE x ( 16 - length($str) );
             if ( !defined($ws_1) ) { $ws_1 = "*" }
             if ( !defined($ws_2) ) { $ws_2 = "*" }
             if ( !defined($ws_3) ) { $ws_3 = "*" }
@@ -4046,7 +4050,7 @@ EOM
         my $code_bias = -.01;    # bias for closing block braces
 
         my $type         = 'b';
-        my $token        = ' ';
+        my $token        = SPACE;
         my $token_length = 1;
         my $last_type;
         my $last_nonblank_type  = $type;
@@ -4534,7 +4538,7 @@ EOM
 
             DEBUG_BOND && do {
                 my $str = substr( $token, 0, 15 );
-                $str .= ' ' x ( 16 - length($str) );
+                $str .= SPACE x ( 16 - length($str) );
                 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";
 
@@ -4574,7 +4578,7 @@ sub bad_pattern {
 
         # Include keywords here which should not be cuddled
 
-        my $cuddled_string = "";
+        my $cuddled_string = EMPTY_STRING;
         if ( $rOpts->{'cuddled-else'} ) {
 
             # set the default
@@ -4587,7 +4591,7 @@ sub bad_pattern {
             # Add users other blocks to be cuddled
             my $cuddled_block_list = $rOpts->{'cuddled-block-list'};
             if ($cuddled_block_list) {
-                $cuddled_string .= " " . $cuddled_block_list;
+                $cuddled_string .= SPACE . $cuddled_block_list;
             }
 
         }
@@ -4703,9 +4707,9 @@ sub dump_cuddled_block_list {
     # easier to manage.
 
     my $cuddled_string = $rOpts->{'cuddled-block-list'};
-    $cuddled_string = '' unless $cuddled_string;
+    $cuddled_string = EMPTY_STRING unless $cuddled_string;
 
-    my $flags = "";
+    my $flags = EMPTY_STRING;
     $flags .= "-ce" if ( $rOpts->{'cuddled-else'} );
     $flags .= " -cbl='$cuddled_string'";
 
@@ -4898,7 +4902,7 @@ sub make_bli_pattern {
 
     # default list of block types for which -bli would apply
     my $bli_list_string = 'if else elsif unless while for foreach do : sub';
-    my $bli_exclusion_list_string = ' ';
+    my $bli_exclusion_list_string = SPACE;
 
     if ( defined( $rOpts->{'brace-left-and-indent-list'} )
         && $rOpts->{'brace-left-and-indent-list'} )
@@ -4924,7 +4928,7 @@ sub make_keyword_group_list_pattern {
     # turn any input list into a regex for recognizing selected block types.
     # Here are the defaults:
     $keyword_group_list_pattern         = '^(our|local|my|use|require|)$';
-    $keyword_group_list_comment_pattern = '';
+    $keyword_group_list_comment_pattern = EMPTY_STRING;
     if ( defined( $rOpts->{'keyword-group-blanks-list'} )
         && $rOpts->{'keyword-group-blanks-list'} )
     {
@@ -4943,7 +4947,7 @@ sub make_keyword_group_list_pattern {
         $keyword_group_list_pattern =
           make_block_pattern( '-kgbl', $rOpts->{'keyword-group-blanks-list'} );
         $keyword_group_list_comment_pattern =
-          make_block_pattern( '-kgbl', join( ' ', @comment_list ) );
+          make_block_pattern( '-kgbl', join( SPACE, @comment_list ) );
     }
     return;
 }
@@ -5032,7 +5036,7 @@ sub make_block_pattern {
     if ( !@words ) { push @words, "1 " }
 
     my $pattern      = '(' . join( '|', @words ) . ')$';
-    my $sub_patterns = "";
+    my $sub_patterns = EMPTY_STRING;
     if ( $seen{'sub'} ) {
         $sub_patterns .= '|' . $SUB_PATTERN;
     }
@@ -5159,7 +5163,7 @@ EOM
             my $seqno = $rtype_sequence->[$j];
             my $token = $rtokens->[$j];
             my $type  = $rtoken_type->[$j];
-            $seqno = "" unless ( defined($seqno) );
+            $seqno = EMPTY_STRING unless ( defined($seqno) );
             my $err_msg =
 "Error at j=$j, line number $input_line_no, seqno='$seqno', type='$type', tok='$token':\n";
 
@@ -5288,15 +5292,15 @@ EOM
         # Data needed by Logger
         $line_of_tokens->{_level_0}          = 0;
         $line_of_tokens->{_ci_level_0}       = 0;
-        $line_of_tokens->{_nesting_blocks_0} = "";
-        $line_of_tokens->{_nesting_tokens_0} = "";
+        $line_of_tokens->{_nesting_blocks_0} = EMPTY_STRING;
+        $line_of_tokens->{_nesting_tokens_0} = EMPTY_STRING;
 
         # Needed to avoid trimming quotes
         $line_of_tokens->{_ended_in_blank_token} = undef;
 
         my $line_type   = $line_of_tokens_old->{_line_type};
         my $line_number = $line_of_tokens_old->{_line_number};
-        my $CODE_type   = "";
+        my $CODE_type   = EMPTY_STRING;
         my $tee_output;
 
         # Handle line of non-code
@@ -5448,7 +5452,7 @@ EOM
 
                     }
                     else {
-                        $seqno = "" unless ( defined($seqno) );
+                        $seqno = EMPTY_STRING unless ( defined($seqno) );
                     }
 
                     my @tokary;
@@ -5659,7 +5663,7 @@ sub set_CODE_type {
         ( $Kfirst, $Klast ) = @{$rK_range};
 
         my $last_CODE_type = $CODE_type;
-        $CODE_type = "";
+        $CODE_type = EMPTY_STRING;
 
         my $input_line = $line_of_tokens->{_line_text};
         my $jmax       = defined($Kfirst) ? $Klast - $Kfirst : -1;
@@ -5681,7 +5685,7 @@ sub set_CODE_type {
                 && ( substr( $rLL->[$Kfirst]->[_TOKEN_], 0, 4 ) eq '#>>>'
                     || $rOpts_format_skipping_end )
 
-                && ( $rLL->[$Kfirst]->[_TOKEN_] . " " ) =~
+                && ( $rLL->[$Kfirst]->[_TOKEN_] . SPACE ) =~
                 /$format_skipping_pattern_end/
               )
             {
@@ -5717,7 +5721,7 @@ sub set_CODE_type {
                 || $rOpts_format_skipping_begin )
 
             && $rOpts_format_skipping
-            && ( $rLL->[$Kfirst]->[_TOKEN_] . " " ) =~
+            && ( $rLL->[$Kfirst]->[_TOKEN_] . SPACE ) =~
             /$format_skipping_pattern_begin/
           )
         {
@@ -6047,12 +6051,12 @@ EOM
             # This may produce multiple blanks in a row, but sub respace_tokens
             # will check for this and fix it.
             $rLL->[$Klast]->[_TYPE_]  = 'b';
-            $rLL->[$Klast]->[_TOKEN_] = ' ';
+            $rLL->[$Klast]->[_TOKEN_] = SPACE;
 
             # The -io option outputs the line text, so we have to update
             # the line text so that the comment does not reappear.
             if ( $CODE_type eq 'IO' ) {
-                my $line = "";
+                my $line = EMPTY_STRING;
                 foreach my $KK ( $Kfirst .. $Klast - 1 ) {
                     $line .= $rLL->[$KK]->[_TOKEN_];
                 }
@@ -6157,8 +6161,8 @@ sub respace_tokens {
     my $Klast_old_code;                # K of last token if side comment
     my $Kmax = @{$rLL} - 1;
 
-    my $CODE_type = "";
-    my $line_type = "";
+    my $CODE_type = EMPTY_STRING;
+    my $line_type = EMPTY_STRING;
 
     # Set the whitespace flags, which indicate the token spacing preference.
     my $rwhitespace_flags = $self->set_whitespace_flags();
@@ -6202,7 +6206,7 @@ sub respace_tokens {
 
     my $last_nonblank_code_type       = ';';
     my $last_nonblank_code_token      = ';';
-    my $last_nonblank_block_type      = '';
+    my $last_nonblank_block_type      = EMPTY_STRING;
     my $last_last_nonblank_code_type  = ';';
     my $last_last_nonblank_code_token = ';';
 
@@ -6228,7 +6232,7 @@ sub respace_tokens {
 
         my $type       = $item->[_TYPE_];
         my $is_blank   = $type eq 'b';
-        my $block_type = "";
+        my $block_type = EMPTY_STRING;
 
         # Do not output consecutive blanks. This situation should have been
         # prevented earlier, but it is worth checking because later routines
@@ -6441,8 +6445,8 @@ sub respace_tokens {
         {
             my $rcopy = [ @{$item} ];
             $rcopy->[_TYPE_]          = 'b';
-            $rcopy->[_TOKEN_]         = ' ';
-            $rcopy->[_TYPE_SEQUENCE_] = '';
+            $rcopy->[_TOKEN_]         = SPACE;
+            $rcopy->[_TYPE_SEQUENCE_] = EMPTY_STRING;
 
             $rcopy->[_LINE_INDEX_] =
               $rLL_new->[-1]->[_LINE_INDEX_];
@@ -6554,12 +6558,12 @@ sub respace_tokens {
             # convert the blank into a semicolon..
             # be careful: we are working on the new stack top
             # on a token which has been stored.
-            my $rcopy = copy_token_as_type( $rLL_new->[$Ktop], 'b', ' ' );
+            my $rcopy = copy_token_as_type( $rLL_new->[$Ktop], 'b', SPACE );
 
             # Convert the existing blank to:
             #   a phantom semicolon for one_line_block option = 0 or 1
             #   a real semicolon    for one_line_block option = 2
-            my $tok     = '';
+            my $tok     = EMPTY_STRING;
             my $len_tok = 0;
             if ( $rOpts_one_line_block_semicolons == 2 ) {
                 $tok     = ';';
@@ -6603,7 +6607,8 @@ sub respace_tokens {
                 }
             }
 
-            my $rcopy = copy_token_as_type( $rLL_new->[$Kp], ';', '' );
+            my $rcopy =
+              copy_token_as_type( $rLL_new->[$Kp], ';', EMPTY_STRING );
             $store_token->($rcopy);
             push @{$rK_phantom_semicolons}, @{$rLL_new} - 1;
         }
@@ -6636,14 +6641,14 @@ sub respace_tokens {
         my $previous_nonblank_token = $rLL_new->[$Kp]->[_TOKEN_];
 
         my $previous_nonblank_type_2  = 'b';
-        my $previous_nonblank_token_2 = "";
+        my $previous_nonblank_token_2 = EMPTY_STRING;
         my $Kpp = $self->K_previous_nonblank( $Kp, $rLL_new );
         if ( defined($Kpp) ) {
             $previous_nonblank_type_2  = $rLL_new->[$Kpp]->[_TYPE_];
             $previous_nonblank_token_2 = $rLL_new->[$Kpp]->[_TOKEN_];
         }
 
-        my $next_nonblank_token = "";
+        my $next_nonblank_token = EMPTY_STRING;
         my $Kn                  = $KK + 1;
         if ( $Kn <= $Kmax && $rLL->[$Kn]->[_TYPE_] eq 'b' ) { $Kn += 1 }
         if ( $Kn <= $Kmax ) {
@@ -6762,9 +6767,10 @@ sub respace_tokens {
                     # hanging side comment from getting converted to a block
                     # comment if whitespace gets deleted, as for example with
                     # the -extrude and -mangle options.
-                    my $rcopy = copy_token_as_type( $rvars_Kfirst, 'q', '' );
+                    my $rcopy =
+                      copy_token_as_type( $rvars_Kfirst, 'q', EMPTY_STRING );
                     $store_token->($rcopy);
-                    $rcopy = copy_token_as_type( $rvars_Kfirst, 'b', ' ' );
+                    $rcopy = copy_token_as_type( $rvars_Kfirst, 'b', SPACE );
                     $store_token->($rcopy);
                     $store_token->($rvars_Kfirst);
                     next;
@@ -6777,7 +6783,7 @@ sub respace_tokens {
                         "Program bug. A hanging side comment has been mismarked"
                     ) if (DEVEL_MODE);
 
-                    $CODE_type = "";
+                    $CODE_type = EMPTY_STRING;
                     $line_of_tokens->{_code_type} = $CODE_type;
                 }
             }
@@ -6835,7 +6841,7 @@ sub respace_tokens {
             {
 
                 # Copy this first token as blank, but use previous line number
-                my $rcopy = copy_token_as_type( $rLL->[$Kfirst], 'b', ' ' );
+                my $rcopy = copy_token_as_type( $rLL->[$Kfirst], 'b', SPACE );
                 $rcopy->[_LINE_INDEX_] =
                   $rLL_new->[-1]->[_LINE_INDEX_];
 
@@ -6901,7 +6907,7 @@ sub respace_tokens {
                 }
 
                 # make it just one character
-                $rtoken_vars->[_TOKEN_] = ' ';
+                $rtoken_vars->[_TOKEN_] = SPACE;
                 $store_token->($rtoken_vars);
                 next;
             }
@@ -6984,7 +6990,7 @@ sub respace_tokens {
                         && $want_left_space{'->'} == WS_YES )
                     {
                         my $rcopy =
-                          copy_token_as_type( $rtoken_vars, 'b', ' ' );
+                          copy_token_as_type( $rtoken_vars, 'b', SPACE );
                         $store_token->($rcopy);
                     }
 
@@ -6996,7 +7002,7 @@ sub respace_tokens {
                     # added for issue git #33
                     if ( $want_right_space{'->'} == WS_YES ) {
                         my $rcopy_b =
-                          copy_token_as_type( $rtoken_vars, 'b', ' ' );
+                          copy_token_as_type( $rtoken_vars, 'b', SPACE );
                         $store_token->($rcopy_b);
                     }
 
@@ -7248,7 +7254,7 @@ EOM
         # container. This fixes case b1085. To find the corresponding code in
         # Tokenizer.pm search for 'b1085' with an editor.
         my $block_type = $rblock_type_of_seqno->{$seqno};
-        if ( $block_type && substr( $block_type, -1, 1 ) eq ' ' ) {
+        if ( $block_type && substr( $block_type, -1, 1 ) eq SPACE ) {
 
             # Always remove the trailing space
             $block_type =~ s/\s+$//;
@@ -7270,7 +7276,7 @@ EOM
             # Convert to a hash brace if it looks like it holds a list
             if ($is_list) {
 
-                $block_type = "";
+                $block_type = EMPTY_STRING;
 
                 $rLL_new->[$K_opening]->[_CI_LEVEL_] = 1;
                 $rLL_new->[$K_closing]->[_CI_LEVEL_] = 1;
@@ -7399,10 +7405,10 @@ sub copy_token_as_type {
     # slightly modifying an existing token.
     my ( $rold_token, $type, $token ) = @_;
     if ( $type eq 'b' ) {
-        $token = " " unless defined($token);
+        $token = SPACE unless defined($token);
     }
     elsif ( $type eq 'q' ) {
-        $token = '' unless defined($token);
+        $token = EMPTY_STRING unless defined($token);
     }
     elsif ( $type eq '->' ) {
         $token = '->' unless defined($token);
@@ -7428,7 +7434,7 @@ EOM
     my @rnew_token = @{$rold_token};
     $rnew_token[_TYPE_]          = $type;
     $rnew_token[_TOKEN_]         = $token;
-    $rnew_token[_TYPE_SEQUENCE_] = '';
+    $rnew_token[_TYPE_SEQUENCE_] = EMPTY_STRING;
     return \@rnew_token;
 }
 
@@ -8604,7 +8610,7 @@ sub setup_new_weld_measurements {
     my $starting_ci;
     my $starting_lentot;
     my $maximum_text_length;
-    my $msg = "";
+    my $msg = EMPTY_STRING;
 
     my $iline_oo = $rLL->[$Kouter_opening]->[_LINE_INDEX_];
     my $rK_range = $rlines->[$iline_oo]->{_rK_range};
@@ -8995,7 +9001,7 @@ sub weld_nested_containers {
         $previous_pair = $item;
 
         my $do_not_weld_rule = 0;
-        my $Msg              = "";
+        my $Msg              = EMPTY_STRING;
         my $is_one_line_weld;
 
         my $iline_oo = $outer_opening->[_LINE_INDEX_];
@@ -9568,7 +9574,7 @@ sub weld_nested_quotes {
               );
 
             # OK: This is a candidate for welding
-            my $Msg = "";
+            my $Msg = EMPTY_STRING;
             my $do_not_weld;
 
             my $Kouter_opening = $K_opening_container->{$outer_seqno};
@@ -9611,7 +9617,7 @@ sub weld_nested_quotes {
             }
 
             if (DEBUG_WELD) {
-                if ( !$is_old_weld ) { $is_old_weld = "" }
+                if ( !$is_old_weld ) { $is_old_weld = EMPTY_STRING }
                 $Msg .=
 "excess=$excess>=$excess_max, multiline_tol=$multiline_tol, is_old_weld='$is_old_weld'\n";
             }
@@ -10005,7 +10011,7 @@ sub whitespace_cycle_adjustment {
         my $whitespace_last_level  = -1;
         my @whitespace_level_stack = ();
         my $last_nonblank_type     = 'b';
-        my $last_nonblank_token    = '';
+        my $last_nonblank_token    = EMPTY_STRING;
         foreach my $KK ( 0 .. $Kmax ) {
             my $level_abs = $radjusted_levels->[$KK];
             my $level     = $level_abs;
@@ -10240,7 +10246,7 @@ sub break_before_list_opening_containers {
 
             #  break if this list contains a broken list with line-ending comma
             my $ok_to_break;
-            my $Msg = "";
+            my $Msg = EMPTY_STRING;
             if ($has_list_with_lec) {
                 $ok_to_break = 1;
                 DEBUG_BBX && do { $Msg = "has list with lec;" };
@@ -11552,7 +11558,7 @@ sub process_all_lines {
     # set locations for blanks around long runs of keywords
     my $rwant_blank_line_after = $self->keyword_group_scan();
 
-    my $line_type      = "";
+    my $line_type      = EMPTY_STRING;
     my $i_last_POD_END = -10;
     my $i              = -1;
     foreach my $line_of_tokens ( @{$rlines} ) {
@@ -11756,7 +11762,7 @@ EOM
 
         # Turn this option off so that this message does not keep repeating
         # during iterations and other files.
-        $rOpts->{'keyword-group-blanks-size'} = "";
+        $rOpts->{'keyword-group-blanks-size'} = EMPTY_STRING;
         return $rhash_of_desires;
     }
     $Opt_size_min = 1 unless ($Opt_size_min);
@@ -12066,7 +12072,7 @@ EOM
           if ( $Opt_repeat_count > 0
             && $number_of_groups_seen >= $Opt_repeat_count );
 
-        $CODE_type = "";
+        $CODE_type = EMPTY_STRING;
         $K_first   = undef;
         $K_last    = undef;
         $line_type = $line_of_tokens->{_line_type};
@@ -12515,7 +12521,7 @@ EOM
         # Initialize some sequence-dependent variables to their normal values
         $parent_seqno_to_go[$max_index_to_go]  = $next_parent_seqno;
         $nesting_depth_to_go[$max_index_to_go] = $next_slevel;
-        $block_type_to_go[$max_index_to_go]    = "";
+        $block_type_to_go[$max_index_to_go]    = EMPTY_STRING;
 
         # Then fix them at container tokens:
         if ($seqno) {
@@ -12794,7 +12800,7 @@ EOM
 
         # Add interline blank if any
         my $last_old_nonblank_type   = "b";
-        my $first_new_nonblank_token = "";
+        my $first_new_nonblank_token = EMPTY_STRING;
         my $K_first_true             = $K_first;
         if ( $max_index_to_go >= 0 ) {
             $last_old_nonblank_type   = $types_to_go[$max_index_to_go];
@@ -13083,7 +13089,7 @@ EOM
             if ( $type eq ';' ) {
 
                 my $next_nonblank_token_type = 'b';
-                my $next_nonblank_token      = '';
+                my $next_nonblank_token      = EMPTY_STRING;
                 if ( $Ktoken_vars < $K_last ) {
                     my $Knnb = $Ktoken_vars + 1;
                     $Knnb++ if ( $rLL->[$Knnb]->[_TYPE_] eq 'b' );
@@ -13202,7 +13208,7 @@ EOM
             elsif ($is_closing_BLOCK) {
 
                 my $next_nonblank_token_type = 'b';
-                my $next_nonblank_token      = '';
+                my $next_nonblank_token      = EMPTY_STRING;
                 my $Knnb;
                 if ( $Ktoken_vars < $K_last ) {
                     $Knnb = $Ktoken_vars + 1;
@@ -13757,9 +13763,9 @@ sub starting_one_line_block {
     my $is_bli            = $ris_bli_container->{$type_sequence_j};
 
     my $block_type = $rblock_type_of_seqno->{$type_sequence_j};
-    $block_type = "" unless ( defined($block_type) );
+    $block_type = EMPTY_STRING unless ( defined($block_type) );
 
-    my $previous_nonblank_token = '';
+    my $previous_nonblank_token = EMPTY_STRING;
     my $i_last_nonblank         = -1;
     if ( defined($K_last_nonblank) ) {
         $i_last_nonblank = $K_last_nonblank - $K_to_go[0];
@@ -14234,7 +14240,7 @@ sub compare_indentation_levels {
             my $msg =
 "FORCE $forced_breakpoint_count after call from $a $c with i=$i max=$max_index_to_go";
             if ( !defined($i_nonblank) ) {
-                $i = "" unless defined($i);
+                $i = EMPTY_STRING unless defined($i);
                 $msg .= " but could not set break after i='$i'\n";
             }
             else {
@@ -14528,19 +14534,22 @@ EOM
         # This routine is only called from sub flush_batch_of_code, so that
         # routine is a better spot for debugging.
         DEBUG_GRIND && do {
-            my $token = my $type = "";
+            my $token = my $type = EMPTY_STRING;
             if ( $max_index_to_go >= 0 ) {
                 $token = $tokens_to_go[$max_index_to_go];
                 $type  = $types_to_go[$max_index_to_go];
             }
-            my $output_str = "";
+            my $output_str = EMPTY_STRING;
             if ( $max_index_to_go > 20 ) {
                 my $mm = $max_index_to_go - 10;
-                $output_str = join( "", @tokens_to_go[ 0 .. 10 ] ) . " ... "
-                  . join( "", @tokens_to_go[ $mm .. $max_index_to_go ] );
+                $output_str =
+                  join( EMPTY_STRING, @tokens_to_go[ 0 .. 10 ] ) . " ... "
+                  . join( EMPTY_STRING,
+                    @tokens_to_go[ $mm .. $max_index_to_go ] );
             }
             else {
-                $output_str = join "", @tokens_to_go[ 0 .. $max_index_to_go ];
+                $output_str = join EMPTY_STRING,
+                  @tokens_to_go[ 0 .. $max_index_to_go ];
             }
             print STDERR <<EOM;
 grind got batch number $batch_count with $max_index_to_go tokens, last type '$type' tok='$token', text:
@@ -14753,7 +14762,7 @@ EOM
         if ( $imin > $imax ) {
             if (DEVEL_MODE) {
                 my $K0  = $K_to_go[0];
-                my $lno = "";
+                my $lno = EMPTY_STRING;
                 if ( defined($K0) ) { $lno = $rLL->[$K0]->[_LINE_INDEX_] + 1 }
                 Fault(<<EOM);
 Strange: received batch containing only blanks near input line $lno: after trimming imin=$imin, imax=$imax
@@ -15253,8 +15262,8 @@ sub pad_array_to_go {
     # some undef's to help guard against using invalid data.
     my ($self) = @_;
     $K_to_go[ $max_index_to_go + 1 ]             = undef;
-    $tokens_to_go[ $max_index_to_go + 1 ]        = '';
-    $tokens_to_go[ $max_index_to_go + 2 ]        = '';
+    $tokens_to_go[ $max_index_to_go + 1 ]        = EMPTY_STRING;
+    $tokens_to_go[ $max_index_to_go + 2 ]        = EMPTY_STRING;
     $tokens_to_go[ $max_index_to_go + 3 ]        = undef;
     $types_to_go[ $max_index_to_go + 1 ]         = 'b';
     $types_to_go[ $max_index_to_go + 2 ]         = 'b';
@@ -15575,7 +15584,7 @@ sub break_equals {
     return unless ( $nmax >= 2 );
 
     # scan the left ends of first two lines
-    my $tokbeg = "";
+    my $tokbeg = EMPTY_STRING;
     my $depth_beg;
     for my $n ( 1 .. 2 ) {
         my $il     = $ri_left->[$n];
@@ -15698,7 +15707,7 @@ sub break_equals {
         for my $n ( 0 .. @{$ri_end} - 1 ) {
             my $ibeg = $ri_beg->[$n];
             my $iend = $ri_end->[$n];
-            my $text = "";
+            my $text = EMPTY_STRING;
             foreach my $i ( $ibeg .. $iend ) {
                 $text .= $tokens_to_go[$i];
             }
@@ -15768,9 +15777,9 @@ sub break_equals {
 
             # ...ok, then make the semicolon invisible
             my $len = $token_lengths_to_go[$i_semicolon];
-            $tokens_to_go[$i_semicolon]            = "";
+            $tokens_to_go[$i_semicolon]            = EMPTY_STRING;
             $token_lengths_to_go[$i_semicolon]     = 0;
-            $rLL->[$K_semicolon]->[_TOKEN_]        = "";
+            $rLL->[$K_semicolon]->[_TOKEN_]        = EMPTY_STRING;
             $rLL->[$K_semicolon]->[_TOKEN_LENGTH_] = 0;
             foreach ( $i_semicolon .. $max_index_to_go ) {
                 $summed_lengths_to_go[ $_ + 1 ] -= $len;
@@ -17621,12 +17630,12 @@ sub break_long_lines {
     my $i_last_break            = -1;
     my $max_bias                = 0.001;
     my $tiny_bias               = 0.0001;
-    my $leading_alignment_token = "";
-    my $leading_alignment_type  = "";
+    my $leading_alignment_token = EMPTY_STRING;
+    my $leading_alignment_type  = EMPTY_STRING;
 
     # see if any ?/:'s are in order
     my $colons_in_order = 1;
-    my $last_tok        = "";
+    my $last_tok        = EMPTY_STRING;
     foreach ( @{$rcolon_list} ) {
         if ( $_ eq $last_tok ) { $colons_in_order = 0; last }
         $last_tok = $_;
@@ -17635,7 +17644,7 @@ sub break_long_lines {
     # This is a sufficient but not necessary condition for colon chain
     my $is_colon_chain = ( $colons_in_order && @{$rcolon_list} > 2 );
 
-    my $Msg = "";
+    my $Msg = EMPTY_STRING;
 
     #-------------------------------------------------------
     # BEGINNING of main loop to set continuation breakpoints
@@ -17646,7 +17655,7 @@ sub break_long_lines {
         my $starting_sum           = $summed_lengths_to_go[$i_begin];
         my $i_lowest               = -1;
         my $i_test                 = -1;
-        my $lowest_next_token      = '';
+        my $lowest_next_token      = EMPTY_STRING;
         my $lowest_next_type       = 'b';
         my $i_lowest_next_nonblank = -1;
         my $maximum_line_length =
@@ -18032,8 +18041,9 @@ sub break_long_lines {
             }
 
             DEBUG_BREAK_LINES && do {
-                my $ltok     = $token;
-                my $rtok     = $next_nonblank_token ? $next_nonblank_token : "";
+                my $ltok = $token;
+                my $rtok =
+                  $next_nonblank_token ? $next_nonblank_token : EMPTY_STRING;
                 my $i_testp2 = $i_test + 2;
                 if ( $i_testp2 > $max_index_to_go + 1 ) {
                     $i_testp2 = $max_index_to_go + 1;
@@ -18128,7 +18138,7 @@ sub break_long_lines {
         DEBUG_BREAK_LINES
           && print STDOUT
 "BREAK: best is i = $i_lowest strength = $lowest_strength;\nReason>> $Msg\n";
-        $Msg = "";
+        $Msg = EMPTY_STRING;
 
         #-------------------------------------------------------
         # ?/: rule 2 : if we break at a '?', then break at its ':'
@@ -18184,9 +18194,9 @@ sub break_long_lines {
         $i_begin                 = $i_lowest + 1;
         $last_break_strength     = $lowest_strength;
         $i_last_break            = $i_lowest;
-        $leading_alignment_token = "";
-        $leading_alignment_type  = "";
-        $lowest_next_token       = '';
+        $leading_alignment_token = EMPTY_STRING;
+        $leading_alignment_type  = EMPTY_STRING;
+        $lowest_next_token       = EMPTY_STRING;
         $lowest_next_type        = 'b';
 
         if ( ( $i_begin <= $imax ) && ( $types_to_go[$i_begin] eq 'b' ) ) {
@@ -18371,12 +18381,12 @@ sub break_long_lines {
 
             $override_cab3[$depth_t]          = undef;
             $breakpoint_stack[$depth_t]       = $starting_breakpoint_count;
-            $container_type[$depth_t]         = "";
+            $container_type[$depth_t]         = EMPTY_STRING;
             $identifier_count_stack[$depth_t] = 0;
             $index_before_arrow[$depth_t]     = -1;
             $interrupted_list[$depth_t]       = 1;
             $item_count_stack[$depth_t]       = 0;
-            $last_nonblank_type[$depth_t]     = "";
+            $last_nonblank_type[$depth_t]     = EMPTY_STRING;
             $opening_structure_index_stack[$depth_t] = -1;
 
             $breakpoint_undo_stack[$depth_t]       = undef;
@@ -18689,19 +18699,19 @@ EOM
 
         $starting_depth = $nesting_depth_to_go[0];
 
-        $block_type                = ' ';
+        $block_type                = SPACE;
         $current_depth             = $starting_depth;
         $i                         = -1;
         $last_nonblank_token       = ';';
         $last_nonblank_type        = ';';
-        $last_nonblank_block_type  = ' ';
+        $last_nonblank_block_type  = SPACE;
         $last_old_breakpoint_count = 0;
         $minimum_depth = $current_depth + 1;    # forces update in check below
         $old_breakpoint_count      = 0;
         $starting_breakpoint_count = $forced_breakpoint_count;
         $token                     = ';';
         $type                      = ';';
-        $type_sequence             = '';
+        $type_sequence             = EMPTY_STRING;
 
         my $total_depth_variation = 0;
         my $i_old_assignment_break;
@@ -19028,7 +19038,7 @@ EOM
                   #      k => && || ? : .
                   $is_container_label_type{$last_nonblank_type}
                   ? $last_nonblank_token
-                  : "";
+                  : EMPTY_STRING;
                 $identifier_count_stack[$depth]        = 0;
                 $index_before_arrow[$depth]            = -1;
                 $interrupted_list[$depth]              = 0;
@@ -19056,7 +19066,7 @@ EOM
                 $dont_align[$depth] =
 
                   # code BLOCKS are handled at a higher level
-                  ( $block_type ne "" )
+                  ( $block_type ne EMPTY_STRING )
 
                   # certain paren lists
                   || ( $type eq '(' ) && (
@@ -21154,9 +21164,9 @@ sub get_available_spaces_to_go {
             $K_last_nonblank = $Kpnb;
         }
 
-        my $last_nonblank_token     = '';
-        my $last_nonblank_type      = '';
-        my $last_last_nonblank_type = '';
+        my $last_nonblank_token     = EMPTY_STRING;
+        my $last_nonblank_type      = EMPTY_STRING;
+        my $last_last_nonblank_type = EMPTY_STRING;
 
         if ( defined($K_last_nonblank) ) {
             $last_nonblank_token = $rLL->[$K_last_nonblank]->[_TOKEN_];
@@ -22617,7 +22627,7 @@ EOM
             # or is a single token followed by opening token.
             # Note that sub identifiers have blanks like 'sub doit'
             #                                 $token_beg !~ /\s+/
-            || ( $Kend - $Kbeg <= 2 && index( $token_beg, ' ' ) < 0 )
+            || ( $Kend - $Kbeg <= 2 && index( $token_beg, SPACE ) < 0 )
           )
 
           # and limit total to 10 character widths
@@ -22642,7 +22652,7 @@ EOM
 sub check_batch_summed_lengths {
 
     my ( $self, $msg ) = @_;
-    $msg = "" unless defined($msg);
+    $msg = EMPTY_STRING unless defined($msg);
     my $rLL = $self->[_rLL_];
 
     # Verify that the summed lengths are correct. We want to be sure that
@@ -22882,7 +22892,7 @@ EOM
 
                 my $type           = $types_to_go[$i];
                 my $token          = $tokens_to_go[$i];
-                my $alignment_type = '';
+                my $alignment_type = EMPTY_STRING;
 
                 # ----------------------------------------------
                 # Check for 'paren patch' : Remove excess parens
@@ -22922,7 +22932,7 @@ EOM
                         && $imate > $i_good_paren )
                     {
                         if ( $ralignment_type_to_go->[$imate] ) {
-                            $ralignment_type_to_go->[$imate] = '';
+                            $ralignment_type_to_go->[$imate] = EMPTY_STRING;
                             $ralignment_counts->[$line]--;
                             delete $ralignment_hash_by_line->[$line]->{$imate};
                         }
@@ -22986,7 +22996,7 @@ EOM
                     # (2) doing so may prevent other good alignments.
                     # Current exceptions are && and || and =>
                     if ( $i == $iend ) {
-                        $alignment_type = ""
+                        $alignment_type = EMPTY_STRING
                           unless ( $is_terminal_alignment_type{$type} );
                     }
 
@@ -23011,7 +23021,7 @@ EOM
                         && $i == $ibeg + 2
                         && $types_to_go[ $i - 1 ] eq 'b' )
                     {
-                        $alignment_type = "";
+                        $alignment_type = EMPTY_STRING;
                     }
 
                     # Certain tokens only align at the same level as the
@@ -23019,7 +23029,7 @@ EOM
                     if (   $is_low_level_alignment_token{$token}
                         && $levels_to_go[$i] != $level_beg )
                     {
-                        $alignment_type = "";
+                        $alignment_type = EMPTY_STRING;
                     }
 
                     # For a paren after keyword, only align something like this:
@@ -23028,7 +23038,7 @@ EOM
                     if ( $token eq '(' ) {
 
                         if ( $vert_last_nonblank_type eq 'k' ) {
-                            $alignment_type = ""
+                            $alignment_type = EMPTY_STRING
                               unless
                               $is_if_unless_elsif{$vert_last_nonblank_token};
                             ##unless $vert_last_nonblank_token =~ /^(if|unless|elsif)$/;
@@ -23039,7 +23049,7 @@ EOM
                         if ( !$rOpts_function_paren_vertical_alignment ) {
                             my $seqno = $type_sequence_to_go[$i];
                             if ( $ris_function_call_paren->{$seqno} ) {
-                                $alignment_type = "";
+                                $alignment_type = EMPTY_STRING;
                             }
                         }
 
@@ -23119,7 +23129,7 @@ EOM
 
                     # and ignore any tokens which have leading padded spaces
                     # example: perl527/lop.t
-                    elsif ( substr( $alignment_type, 0, 1 ) eq ' ' ) {
+                    elsif ( substr( $alignment_type, 0, 1 ) eq SPACE ) {
 
                     }
 
@@ -23985,11 +23995,11 @@ sub pad_token {
     my $tok_len = $rLL->[$KK]->[_TOKEN_LENGTH_];
 
     if ( $pad_spaces > 0 ) {
-        $tok = ' ' x $pad_spaces . $tok;
+        $tok = SPACE x $pad_spaces . $tok;
         $tok_len += $pad_spaces;
     }
-    elsif ( $pad_spaces == -1 && $tokens_to_go[$ipad] eq ' ' ) {
-        $tok     = "";
+    elsif ( $pad_spaces == -1 && $tokens_to_go[$ipad] eq SPACE ) {
+        $tok     = EMPTY_STRING;
         $tok_len = 0;
     }
     else {
@@ -24153,15 +24163,17 @@ sub pad_token {
                 $rpatterns = [ $types_to_go[$ibeg] ];
             }
             else {
-                $rfields   = [ join( '', @tokens_to_go[ $ibeg .. $iend ] ) ];
-                $rpatterns = [ join( '', @types_to_go[ $ibeg .. $iend ] ) ];
+                $rfields =
+                  [ join( EMPTY_STRING, @tokens_to_go[ $ibeg .. $iend ] ) ];
+                $rpatterns =
+                  [ join( EMPTY_STRING, @types_to_go[ $ibeg .. $iend ] ) ];
             }
             return [ $rtokens, $rfields, $rpatterns, $rfield_lengths ];
         }
 
         my $i_start        = $ibeg;
         my $depth          = 0;
-        my %container_name = ( 0 => "" );
+        my %container_name = ( 0 => EMPTY_STRING );
 
         my @tokens        = ();
         my @fields        = ();
@@ -24194,7 +24206,7 @@ sub pad_token {
 
                 # Make a container name by combining all leading barewords,
                 # keywords and functions.
-                my $name  = "";
+                my $name  = EMPTY_STRING;
                 my $count = 0;
                 my $count_max;
                 my $iname_end;
@@ -24215,7 +24227,7 @@ sub pad_token {
                         || $is_binary_type{$type}
                         || $type eq 'k' && $is_binary_keyword{$token} )
                     {
-                        $name = "";
+                        $name = EMPTY_STRING;
                         last;
                     }
 
@@ -24241,7 +24253,7 @@ sub pad_token {
                         $token = $name_map{$token};
                     }
 
-                    $name .= ' ' . $token;
+                    $name .= SPACE . $token;
                     $iname_end = $_;
                     $count++;
                 }
@@ -24262,7 +24274,7 @@ sub pad_token {
         # --------------------
         my $j = 0;    # field index
 
-        $patterns[0] = "";
+        $patterns[0] = EMPTY_STRING;
         my %token_count;
         for my $i ( $ibeg .. $iend ) {
 
@@ -24467,7 +24479,7 @@ sub pad_token {
                 # concatenate the text of the consecutive tokens to form
                 # the field
                 push( @fields,
-                    join( '', @tokens_to_go[ $i_start .. $i - 1 ] ) );
+                    join( EMPTY_STRING, @tokens_to_go[ $i_start .. $i - 1 ] ) );
 
                 push @field_lengths,
                   $summed_lengths_to_go[$i] - $summed_lengths_to_go[$i_start];
@@ -24478,7 +24490,7 @@ sub pad_token {
                 # get ready for the next batch
                 $i_start = $i;
                 $j++;
-                $patterns[$j] = "";
+                $patterns[$j] = EMPTY_STRING;
             } ## end if ( new synchronization token
 
             # continue accumulating tokens
@@ -24520,7 +24532,9 @@ sub pad_token {
                         # so that we can align things like this:
                         #  Button   => "Print letter \"~$_\"",
                         #  -command => [ sub { print "$_[0]\n" }, $_ ],
-                        if ( $patterns[$j] eq 'm' ) { $patterns[$j] = "" }
+                        if ( $patterns[$j] eq 'm' ) {
+                            $patterns[$j] = EMPTY_STRING;
+                        }
                     }
                 }
 
@@ -24554,12 +24568,13 @@ sub pad_token {
 
             # remove any zero-level name at first fat comma
             if ( $depth == 0 && $type eq '=>' ) {
-                $container_name{$depth} = "";
+                $container_name{$depth} = EMPTY_STRING;
             }
         } ## end for my $i ( $ibeg .. $iend)
 
         # done with this line .. join text of tokens to make the last field
-        push( @fields, join( '', @tokens_to_go[ $i_start .. $iend ] ) );
+        push( @fields,
+            join( EMPTY_STRING, @tokens_to_go[ $i_start .. $iend ] ) );
         push @field_lengths,
           $summed_lengths_to_go[ $iend + 1 ] - $summed_lengths_to_go[$i_start];
 
@@ -24575,11 +24590,11 @@ sub make_paren_name {
     # Create an alignment name for it to avoid incorrect alignments.
 
     # Start with the name of the previous nonblank token...
-    my $name = "";
+    my $name = EMPTY_STRING;
     my $im   = $i - 1;
-    return "" if ( $im < 0 );
+    return EMPTY_STRING if ( $im < 0 );
     if ( $types_to_go[$im] eq 'b' ) { $im--; }
-    return "" if ( $im < 0 );
+    return EMPTY_STRING if ( $im < 0 );
     $name = $tokens_to_go[$im];
 
     # Prepend any sub name to an isolated -> to avoid unwanted alignments
@@ -24606,7 +24621,7 @@ sub make_paren_name {
     sub initialize_final_indentation_adjustment {
         $last_indentation_written    = 0;
         $last_unadjusted_indentation = 0;
-        $last_leading_token          = "";
+        $last_leading_token          = EMPTY_STRING;
         return;
     }
 
@@ -25640,7 +25655,7 @@ sub set_vertical_tightness_flags {
                 my $ok = 0;
                 if ( $cvt == 2 || $iend_next == $ibeg_next ) { $ok = 1 }
                 else {
-                    my $str = join( '',
+                    my $str = join( EMPTY_STRING,
                         @types_to_go[ $ibeg_next + 1 .. $ibeg_next + 2 ] );
 
                     # append closing token if followed by comment or ';'
@@ -25899,10 +25914,10 @@ sub set_vertical_tightness_flags {
         %block_leading_text           = ();
         %block_opening_line_number    = ();
         $csc_new_statement_ok         = 1;
-        $csc_last_label               = "";
+        $csc_last_label               = EMPTY_STRING;
         %csc_block_label              = ();
         $rleading_block_if_elsif_text = [];
-        $accumulating_text_for_block  = "";
+        $accumulating_text_for_block  = EMPTY_STRING;
         reset_block_text_accumulator();
         return;
     }
@@ -25917,8 +25932,8 @@ sub set_vertical_tightness_flags {
                 push @{$rleading_block_if_elsif_text}, $leading_block_text;
             }
         }
-        $accumulating_text_for_block        = "";
-        $leading_block_text                 = "";
+        $accumulating_text_for_block        = EMPTY_STRING;
+        $leading_block_text                 = EMPTY_STRING;
         $leading_block_text_level           = 0;
         $leading_block_text_length_exceeded = 0;
         $leading_block_text_line_number     = 0;
@@ -25932,7 +25947,7 @@ sub set_vertical_tightness_flags {
         if ( $accumulating_text_for_block !~ /^els/ ) {
             $rleading_block_if_elsif_text = [];
         }
-        $leading_block_text                 = "";
+        $leading_block_text                 = EMPTY_STRING;
         $leading_block_text_level           = $levels_to_go[$i];
         $leading_block_text_line_number     = $self->get_output_line_number();
         $leading_block_text_length_exceeded = 0;
@@ -26006,7 +26021,7 @@ sub set_vertical_tightness_flags {
 
                 # add an extra space at each newline
                 if ( $i == 0 && $types_to_go[$i] ne 'b' ) {
-                    $leading_block_text .= ' ';
+                    $leading_block_text .= SPACE;
                 }
 
                 # add the token text
@@ -26031,17 +26046,18 @@ sub set_vertical_tightness_flags {
         # the text placed after certain closing block braces.
         # Defines and returns the following for this buffer:
 
-        my $block_leading_text = "";    # the leading text of the last '}'
+        my $block_leading_text =
+          EMPTY_STRING;    # the leading text of the last '}'
         my $rblock_leading_if_elsif_text;
         my $i_block_leading_text =
-          -1;    # index of token owning block_leading_text
-        my $block_line_count    = 100;    # how many lines the block spans
-        my $terminal_type       = 'b';    # type of last nonblank token
-        my $i_terminal          = 0;      # index of last nonblank token
-        my $terminal_block_type = "";
+          -1;              # index of token owning block_leading_text
+        my $block_line_count    = 100;          # how many lines the block spans
+        my $terminal_type       = 'b';          # type of last nonblank token
+        my $i_terminal          = 0;            # index of last nonblank token
+        my $terminal_block_type = EMPTY_STRING;
 
         # update most recent statement label
-        $csc_last_label = "" unless ($csc_last_label);
+        $csc_last_label = EMPTY_STRING unless ($csc_last_label);
         if ( $types_to_go[0] eq 'J' ) { $csc_last_label = $tokens_to_go[0] }
         my $block_label = $csc_last_label;
 
@@ -26112,9 +26128,11 @@ sub set_vertical_tightness_flags {
                     # set a label for this block, except for
                     # a bare block which already has the label
                     # A label can only be used on the next {
-                    if ( $block_type =~ /:$/ ) { $csc_last_label = "" }
+                    if ( $block_type =~ /:$/ ) {
+                        $csc_last_label = EMPTY_STRING;
+                    }
                     $csc_block_label{$type_sequence} = $csc_last_label;
-                    $csc_last_label = "";
+                    $csc_last_label = EMPTY_STRING;
 
                     if (   $accumulating_text_for_block
                         && $levels_to_go[$i] == $leading_block_text_level )
@@ -26179,7 +26197,7 @@ sub set_vertical_tightness_flags {
         }
 
         # if this line ends in a label then remember it for the next pass
-        $csc_last_label = "";
+        $csc_last_label = EMPTY_STRING;
         if ( $terminal_type eq 'J' ) {
             $csc_last_label = $tokens_to_go[$i_terminal];
         }
@@ -26228,7 +26246,7 @@ sub set_vertical_tightness_flags {
             return $csc_text;
         }
 
-        my $last_elsif_text = "";
+        my $last_elsif_text = EMPTY_STRING;
         if ( $count > 1 ) {
             $last_elsif_text = ' [elsif' . $rif_elsif_text->[ $count - 1 ];
             if ( $count > 2 ) { $last_elsif_text = ' [...' . $last_elsif_text; }
@@ -26240,7 +26258,7 @@ sub set_vertical_tightness_flags {
             $csc_text .= $last_elsif_text;
         }
         else {
-            $csc_text .= ' ' . $if_text;
+            $csc_text .= SPACE . $if_text;
         }
 
         # all done if no length checks requested
@@ -26394,7 +26412,7 @@ sub add_closing_side_comment {
     {
 
         # then make the closing side comment text
-        if ($block_label) { $block_label .= " " }
+        if ($block_label) { $block_label .= SPACE }
         my $token =
 "$rOpts->{'closing-side-comment-prefix'} $block_label$block_type_to_go[$i_terminal]";
 
@@ -26469,7 +26487,7 @@ sub add_closing_side_comment {
 
                         # save the old side comment in a new trailing block
                         # comment
-                        my $timestamp = "";
+                        my $timestamp = EMPTY_STRING;
                         if ( $rOpts->{'timestamp'} ) {
                             my ( $day, $month, $year ) = (localtime)[ 3, 4, 5 ];
                             $year  += 1900;
@@ -26570,7 +26588,7 @@ sub wrapup {
     my $last_added_semicolon_at  = $self->[_last_added_semicolon_at_];
 
     if ( $added_semicolon_count > 0 ) {
-        my $first = ( $added_semicolon_count > 1 ) ? "First" : "";
+        my $first = ( $added_semicolon_count > 1 ) ? "First" : EMPTY_STRING;
         my $what =
           ( $added_semicolon_count > 1 ) ? "semicolons were" : "semicolon was";
         write_logfile_entry("$added_semicolon_count $what added:\n");
@@ -26589,7 +26607,7 @@ sub wrapup {
     my $first_deleted_semicolon_at = $self->[_first_deleted_semicolon_at_];
     my $last_deleted_semicolon_at  = $self->[_last_deleted_semicolon_at_];
     if ( $deleted_semicolon_count > 0 ) {
-        my $first = ( $deleted_semicolon_count > 1 ) ? "First" : "";
+        my $first = ( $deleted_semicolon_count > 1 ) ? "First" : EMPTY_STRING;
         my $what =
           ( $deleted_semicolon_count > 1 )
           ? "semicolons were"
@@ -26611,7 +26629,7 @@ sub wrapup {
     my $first_embedded_tab_at = $self->[_first_embedded_tab_at_];
     my $last_embedded_tab_at  = $self->[_last_embedded_tab_at_];
     if ( $embedded_tab_count > 0 ) {
-        my $first = ( $embedded_tab_count > 1 ) ? "First" : "";
+        my $first = ( $embedded_tab_count > 1 ) ? "First" : EMPTY_STRING;
         my $what =
           ( $embedded_tab_count > 1 )
           ? "quotes or patterns"
index 909a5abc3c782ed2aeb058cf5945baf64b787a5a..80792ee348f62706be8d5193ffe46d68979873d1 100644 (file)
@@ -12,6 +12,9 @@ our $VERSION = '20220217.04';
 use English qw( -no_match_vars );
 use File::Basename;
 
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
+
 # class variables
 use vars qw{
   %html_color
@@ -169,7 +172,7 @@ PRE_END
         ( $title, my $path ) = fileparse($input_file);
     }
     my $toc_item_count = 0;
-    my $in_toc_package = "";
+    my $in_toc_package = EMPTY_STRING;
     my $last_level     = 0;
     return bless {
         _input_file        => $input_file,          # name of input file
@@ -225,7 +228,7 @@ sub add_toc_item {
     my $end_package_list = sub {
         if ( ${$rin_toc_package} ) {
             $html_toc_fh->print("</ul>\n</li>\n");
-            ${$rin_toc_package} = "";
+            ${$rin_toc_package} = EMPTY_STRING;
         }
         return;
     };
@@ -623,7 +626,7 @@ EOM
         my $long_name = $short_to_long_names{$short_name};
 
         my $abbrev = '.' . $short_name;
-        if ( length($short_name) == 1 ) { $abbrev .= ' ' }    # for alignment
+        if ( length($short_name) == 1 ) { $abbrev .= SPACE }    # for alignment
         my $color = $html_color{$short_name};
         if ( !defined($color) ) { $color = $text_color }
         $fh->print("$abbrev \{ color: $color;");
@@ -773,7 +776,7 @@ sub pod_to_html {
     # the necessary perltidy html sections
     my ( $saw_body, $saw_index, $saw_body_end );
 
-    my $timestamp = "";
+    my $timestamp = EMPTY_STRING;
     if ( $rOpts->{'timestamp'} ) {
         my $date = localtime;
         $timestamp = "on $date";
@@ -848,7 +851,7 @@ sub pod_to_html {
                 my @toc_st = map { $_ . "\n" } split /\n/, $toc_string;
                 $html_print->(@toc_st);
             }
-            $in_toc   = "";
+            $in_toc   = EMPTY_STRING;
             $no_print = 0;
         }
 
@@ -873,7 +876,7 @@ sub pod_to_html {
                     my @toc_st = map { $_ . "\n" } split /\n/, $toc_string;
                     $html_print->(@toc_st);
                 }
-                $in_toc   = "";
+                $in_toc   = EMPTY_STRING;
                 $ul_level = 0;
                 $no_print = 0;
             }
@@ -982,7 +985,7 @@ sub make_frame {
     $title = escape_html($title);
 
     # FUTURE input parameter:
-    my $top_basename = "";
+    my $top_basename = EMPTY_STRING;
 
     # We need to produce 3 html files:
     # 1. - the table of contents
@@ -1030,7 +1033,7 @@ EOM
 
     my $first_anchor =
       change_anchor_names( $rtoc, $src_basename, "$src_frame_name" );
-    $fh->print( join "", @{$rtoc} );
+    $fh->print( join EMPTY_STRING, @{$rtoc} );
 
     $fh->print(<<EOM);
 </body>
@@ -1196,7 +1199,7 @@ ENDCSS
     # --------------------------------------------------
     my $input_file = $self->{_input_file};
     my $title      = escape_html($input_file);
-    my $timestamp  = "";
+    my $timestamp  = EMPTY_STRING;
     if ( $rOpts->{'timestamp'} ) {
         my $date = localtime;
         $timestamp = "on $date";
@@ -1316,7 +1319,7 @@ sub markup_tokens {
 
             # but don't include sub declarations in the toc;
             # these wlll have leading token types 'i;'
-            my $signature = join "", @{$rtoken_type};
+            my $signature = join EMPTY_STRING, @{$rtoken_type};
             unless ( $signature =~ /^i;/ ) {
                 my $subname = $token;
                 $subname =~ s/[\s\(].*$//; # remove any attributes and prototype
@@ -1421,11 +1424,11 @@ sub write_line {
             $html_line = $1;
         }
         else {
-            $html_line = "";
+            $html_line = EMPTY_STRING;
         }
         my ($rcolored_tokens) =
           $self->markup_tokens( $rtokens, $rtoken_type, $rlevels );
-        $html_line .= join '', @{$rcolored_tokens};
+        $html_line .= join EMPTY_STRING, @{$rcolored_tokens};
     }
 
     # markup line of non-code..
@@ -1480,7 +1483,7 @@ EOM
                     # otherwise, just clear the current string and start
                     # over
                     else {
-                        ${$rpre_string} = "";
+                        ${$rpre_string} = EMPTY_STRING;
                         $html_pod_fh->print("\n");
                     }
                 }
@@ -1499,11 +1502,11 @@ EOM
     # add the line number if requested
     if ( $rOpts->{'html-line-numbers'} ) {
         my $extra_space =
-            ( $line_number < 10 )   ? "   "
-          : ( $line_number < 100 )  ? "  "
-          : ( $line_number < 1000 ) ? " "
-          :                           "";
-        $html_line = $extra_space . $line_number . " " . $html_line;
+            ( $line_number < 10 )   ? SPACE x 3
+          : ( $line_number < 100 )  ? SPACE x 2
+          : ( $line_number < 1000 ) ? SPACE
+          :                           EMPTY_STRING;
+        $html_line = $extra_space . $line_number . SPACE . $html_line;
     }
 
     # write the line
index b89e52bf5265399140cdab47fafe39026e224b17..90b16f04a77a74f48d556ba8abb9c574b44389d5 100644 (file)
@@ -12,6 +12,8 @@ use warnings;
 use Carp;
 our $VERSION = '20220217.04';
 
+use constant EMPTY_STRING => q{};
+
 sub AUTOLOAD {
 
     # Catch any undefined sub calls so that we are sure to get
@@ -50,7 +52,7 @@ EOM
 
     }
     if ( $mode eq 'w' ) {
-        ${$rscalar} = "";
+        ${$rscalar} = EMPTY_STRING;
         return bless [ $rscalar, $mode ], $package;
     }
     elsif ( $mode eq 'r' ) {
index cc1117deb954fe9ef36566a79335ec7c0887facf..2830b833bf1c4cec48178c9562a1952546004565 100644 (file)
@@ -9,7 +9,9 @@ use strict;
 use warnings;
 our $VERSION = '20220217.04';
 use English qw( -no_match_vars );
+
 use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
 
 sub AUTOLOAD {
 
@@ -38,6 +40,7 @@ sub DESTROY {
 }
 
 use constant DEFAULT_LOGFILE_GAP => 50;
+
 sub new {
 
     my ( $class, @args ) = @_;
@@ -157,6 +160,7 @@ sub we_are_at_the_last_line {
 
 # record some stuff in case we go down in flames
 use constant MAX_PRINTED_CHARS => 35;
+
 sub black_box {
     my ( $self, $line_of_tokens, $output_line_number ) = @_;
     my $input_line        = $line_of_tokens->{_line_text};
@@ -245,12 +249,12 @@ sub make_line_information_string {
         # for longer scripts it doesn't really matter
         my $extra_space = EMPTY_STRING;
         $extra_space .=
-            ( $input_line_number < 10 )  ? "  "
-          : ( $input_line_number < 100 ) ? " "
+            ( $input_line_number < 10 )  ? SPACE x 2
+          : ( $input_line_number < 100 ) ? SPACE
           :                                EMPTY_STRING;
         $extra_space .=
-            ( $output_line_number < 10 )  ? "  "
-          : ( $output_line_number < 100 ) ? " "
+            ( $output_line_number < 10 )  ? SPACE x 2
+          : ( $output_line_number < 100 ) ? SPACE
           :                                 EMPTY_STRING;
 
         # there are 2 possible nesting strings:
@@ -267,7 +271,7 @@ sub make_line_information_string {
 
         if ( length($nesting_string_new) <= 8 ) {
             $nesting_string =
-              $nesting_string_new . " " x ( 8 - length($nesting_string_new) );
+              $nesting_string_new . SPACE x ( 8 - length($nesting_string_new) );
         }
         $line_information_string =
 "L$input_line_number:$output_line_number$extra_space i$guessed_indentation_level:$structural_indentation_level $ci_level $bk $nesting_string";
@@ -415,7 +419,7 @@ sub warning {
 
                 # add prefix 'filename: ' to message lines
                 if ($filename_stamp) {
-                    my $pre_string = $filename_stamp . " ";
+                    my $pre_string = $filename_stamp . SPACE;
                     chomp $msg;
                     $msg =~ s/\n/\n$pre_string/g;
                     $msg = $pre_string . $msg . "\n";
index 9da515fd2dde13e5569c84a25f4df013bf6a8270..04d85815780d732d32d288737642b594a39eec62 100644 (file)
@@ -25,8 +25,9 @@ use English qw( -no_match_vars );
 
 our $VERSION = '20220217.04';
 
-# this can be turned on for extra checking during development
-use constant DEVEL_MODE => 0;
+use constant DEVEL_MODE   => 0;
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
 
 use Perl::Tidy::LineBuffer;
 use Carp;
@@ -393,8 +394,8 @@ sub new {
     my $self = [];
     $self->[_rhere_target_list_]        = [];
     $self->[_in_here_doc_]              = 0;
-    $self->[_here_doc_target_]          = "";
-    $self->[_here_quote_character_]     = "";
+    $self->[_here_doc_target_]          = EMPTY_STRING;
+    $self->[_here_quote_character_]     = EMPTY_STRING;
     $self->[_in_data_]                  = 0;
     $self->[_in_end_]                   = 0;
     $self->[_in_format_]                = 0;
@@ -403,7 +404,7 @@ sub new {
     $self->[_in_skipped_]               = 0;
     $self->[_in_attribute_list_]        = 0;
     $self->[_in_quote_]                 = 0;
-    $self->[_quote_target_]             = "";
+    $self->[_quote_target_]             = EMPTY_STRING;
     $self->[_line_start_quote_]         = -1;
     $self->[_starting_level_]           = $args{starting_level};
     $self->[_know_starting_level_]      = defined( $args{starting_level} );
@@ -435,7 +436,7 @@ sub new {
     $self->[_unexpected_error_count_]   = 0;
     $self->[_started_looking_for_here_target_at_] = 0;
     $self->[_nearly_matched_here_target_at_]      = undef;
-    $self->[_line_of_text_]                       = "";
+    $self->[_line_of_text_]                       = EMPTY_STRING;
     $self->[_rlower_case_labels_at_]              = undef;
     $self->[_extended_syntax_]                    = $args{extended_syntax};
     $self->[_maximum_level_]                      = 0;
@@ -480,7 +481,7 @@ sub warning {
 }
 
 sub get_input_stream_name {
-    my $input_stream_name = "";
+    my $input_stream_name = EMPTY_STRING;
     my $logger_object     = $tokenizer_self->[_logger_object_];
     if ($logger_object) {
         $input_stream_name = $logger_object->get_input_stream_name();
@@ -793,7 +794,7 @@ sub get_line {
 
     # Find and remove what characters terminate this line, including any
     # control r
-    my $input_line_separator = "";
+    my $input_line_separator = EMPTY_STRING;
     if ( chomp($input_line) ) {
         $input_line_separator = $INPUT_RECORD_SEPARATOR;
     }
@@ -848,7 +849,7 @@ sub get_line {
         _curly_brace_depth         => $brace_depth,
         _square_bracket_depth      => $square_bracket_depth,
         _paren_depth               => $paren_depth,
-        _quote_character           => '',
+        _quote_character           => EMPTY_STRING,
 ##        _rtoken_type               => undef,
 ##        _rtokens                   => undef,
 ##        _rlevels                   => undef,
@@ -898,8 +899,8 @@ sub get_line {
             }
             else {
                 $tokenizer_self->[_in_here_doc_]          = 0;
-                $tokenizer_self->[_here_doc_target_]      = "";
-                $tokenizer_self->[_here_quote_character_] = "";
+                $tokenizer_self->[_here_doc_target_]      = EMPTY_STRING;
+                $tokenizer_self->[_here_quote_character_] = EMPTY_STRING;
             }
         }
 
@@ -1280,7 +1281,7 @@ sub find_starting_indentation_level {
         my $i = 0;
 
         # keep looking at lines until we find a hash bang or piece of code
-        my $msg = "";
+        my $msg = EMPTY_STRING;
         while ( $line =
             $tokenizer_self->[_line_buffer_object_]->peek_ahead( $i++ ) )
         {
@@ -1356,7 +1357,7 @@ sub dump_functions {
         $fh->print("\nnon-constant subs in package $pkg\n");
 
         foreach my $sub ( keys %{ $is_user_function{$pkg} } ) {
-            my $msg = "";
+            my $msg = EMPTY_STRING;
             if ( $is_block_list_function{$pkg}{$sub} ) {
                 $msg = 'block_list';
             }
@@ -1383,10 +1384,10 @@ sub prepare_for_a_new_file {
     # previous tokens needed to determine what to expect next
     $last_nonblank_token      = ';';    # the only possible starting state which
     $last_nonblank_type       = ';';    # will make a leading brace a code block
-    $last_nonblank_block_type = '';
+    $last_nonblank_block_type = EMPTY_STRING;
 
     # scalars for remembering statement types across multiple lines
-    $statement_type    = '';            # '' or 'use' or 'sub..' or 'case..'
+    $statement_type    = EMPTY_STRING;    # '' or 'use' or 'sub..' or 'case..'
     $in_attribute_list = 0;
 
     # scalars for remembering where we are in the file
@@ -1394,9 +1395,9 @@ sub prepare_for_a_new_file {
     $context         = UNKNOWN_CONTEXT;
 
     # hashes used to remember function information
-    %is_constant             = ();      # user-defined constants
-    %is_user_function        = ();      # user-defined functions
-    %user_function_prototype = ();      # their prototypes
+    %is_constant             = ();        # user-defined constants
+    %is_user_function        = ();        # user-defined functions
+    %user_function_prototype = ();        # their prototypes
     %is_block_function       = ();
     %is_block_list_function  = ();
     %saw_function_definition = ();
@@ -1428,15 +1429,15 @@ sub prepare_for_a_new_file {
     @nested_statement_type          = ();
     @starting_line_of_current_depth = ();
 
-    $paren_type[$paren_depth]            = '';
+    $paren_type[$paren_depth]            = EMPTY_STRING;
     $paren_semicolon_count[$paren_depth] = 0;
-    $paren_structural_type[$brace_depth] = '';
+    $paren_structural_type[$brace_depth] = EMPTY_STRING;
     $brace_type[$brace_depth] = ';';    # identify opening brace as code block
-    $brace_structural_type[$brace_depth]                   = '';
+    $brace_structural_type[$brace_depth]                   = EMPTY_STRING;
     $brace_context[$brace_depth]                           = UNKNOWN_CONTEXT;
     $brace_package[$paren_depth]                           = $current_package;
-    $square_bracket_type[$square_bracket_depth]            = '';
-    $square_bracket_structural_type[$square_bracket_depth] = '';
+    $square_bracket_type[$square_bracket_depth]            = EMPTY_STRING;
+    $square_bracket_structural_type[$square_bracket_depth] = EMPTY_STRING;
 
     initialize_tokenizer_state();
     return;
@@ -1513,27 +1514,27 @@ sub prepare_for_a_new_file {
         # TV3:
         $in_quote                = 0;
         $quote_type              = 'Q';
-        $quote_character         = "";
+        $quote_character         = EMPTY_STRING;
         $quote_pos               = 0;
         $quote_depth             = 0;
-        $quoted_string_1         = "";
-        $quoted_string_2         = "";
-        $allowed_quote_modifiers = "";
+        $quoted_string_1         = EMPTY_STRING;
+        $quoted_string_2         = EMPTY_STRING;
+        $allowed_quote_modifiers = EMPTY_STRING;
 
         # TV4:
-        $id_scan_state     = '';
-        $identifier        = '';
-        $want_paren        = "";
+        $id_scan_state     = EMPTY_STRING;
+        $identifier        = EMPTY_STRING;
+        $want_paren        = EMPTY_STRING;
         $indented_if_level = 0;
 
         # TV5:
-        $nesting_token_string             = "";
-        $nesting_type_string              = "";
-        $nesting_block_string             = '1';    # initially in a block
-        $nesting_block_flag               = 1;
-        $nesting_list_string              = '0';    # initially not in a list
-        $nesting_list_flag                = 0;      # initially not in a list
-        $ci_string_in_tokenizer           = "";
+        $nesting_token_string   = EMPTY_STRING;
+        $nesting_type_string    = EMPTY_STRING;
+        $nesting_block_string   = '1';            # initially in a block
+        $nesting_block_flag     = 1;
+        $nesting_list_string    = '0';            # initially not in a list
+        $nesting_list_flag      = 0;              # initially not in a list
+        $ci_string_in_tokenizer = EMPTY_STRING;
         $continuation_string_in_tokenizer = "0";
         $in_statement_continuation        = 0;
         $level_in_tokenizer               = 0;
@@ -1541,14 +1542,14 @@ sub prepare_for_a_new_file {
         $rslevel_stack                    = [];
 
         # TV6:
-        $last_nonblank_container_type      = '';
-        $last_nonblank_type_sequence       = '';
+        $last_nonblank_container_type      = EMPTY_STRING;
+        $last_nonblank_type_sequence       = EMPTY_STRING;
         $last_last_nonblank_token          = ';';
         $last_last_nonblank_type           = ';';
-        $last_last_nonblank_block_type     = '';
-        $last_last_nonblank_container_type = '';
-        $last_last_nonblank_type_sequence  = '';
-        $last_nonblank_prototype           = "";
+        $last_last_nonblank_block_type     = EMPTY_STRING;
+        $last_last_nonblank_container_type = EMPTY_STRING;
+        $last_last_nonblank_type_sequence  = EMPTY_STRING;
+        $last_nonblank_prototype           = EMPTY_STRING;
         return;
     }
 
@@ -1686,8 +1687,8 @@ sub prepare_for_a_new_file {
 
             # Split $tok into up to 3 tokens:
             my $tok_0 = substr( $pretoken, 0, $numc );
-            my $tok_1 = defined($1) ? $1 : "";
-            my $tok_2 = defined($2) ? $2 : "";
+            my $tok_1 = defined($1) ? $1 : EMPTY_STRING;
+            my $tok_2 = defined($2) ? $2 : EMPTY_STRING;
 
             my $len_0 = length($tok_0);
             my $len_1 = length($tok_1);
@@ -1887,7 +1888,7 @@ A space may be needed after '$var'.
 EOM
                 resume_logfile();
             }
-            $id_scan_state = "";
+            $id_scan_state = EMPTY_STRING;
         }
         return;
     }
@@ -1931,7 +1932,7 @@ EOM
 
             # look for $var, @var, ...
             if ( $rtoken_type->[ $i + 1 ] eq 'w' ) {
-                my $pretype_next = "";
+                my $pretype_next = EMPTY_STRING;
                 my $i_next       = $i + 2;
                 if ( $i_next <= $max_token_index ) {
                     if (   $rtoken_type->[$i_next] eq 'b'
@@ -2061,7 +2062,7 @@ EOM
         my $typ_d = $rtoken_type->[$i_d];
 
         # check for signed integer
-        my $sign = "";
+        my $sign = EMPTY_STRING;
         if (   $typ_d ne 'd'
             && ( $typ_d eq '+' || $typ_d eq '-' )
             && $i_d < $max_token_index )
@@ -2266,7 +2267,7 @@ EOM
             $paren_semicolon_count[$paren_depth] = 0;
             if ($want_paren) {
                 $container_type = $want_paren;
-                $want_paren     = "";
+                $want_paren     = EMPTY_STRING;
             }
             elsif ( $statement_type =~ /^sub\b/ ) {
                 $container_type = $statement_type;
@@ -2428,8 +2429,8 @@ EOM
         },
         ';' => sub {
             $context        = UNKNOWN_CONTEXT;
-            $statement_type = '';
-            $want_paren     = "";
+            $statement_type = EMPTY_STRING;
+            $want_paren     = EMPTY_STRING;
 
             #    /^(for|foreach)$/
             if ( $is_for_foreach{ $paren_type[$paren_depth] } )
@@ -2456,21 +2457,21 @@ EOM
               if ( $expecting == OPERATOR );
             $in_quote                = 1;
             $type                    = 'Q';
-            $allowed_quote_modifiers = "";
+            $allowed_quote_modifiers = EMPTY_STRING;
         },
         "'" => sub {
             error_if_expecting_OPERATOR("String")
               if ( $expecting == OPERATOR );
             $in_quote                = 1;
             $type                    = 'Q';
-            $allowed_quote_modifiers = "";
+            $allowed_quote_modifiers = EMPTY_STRING;
         },
         '`' => sub {
             error_if_expecting_OPERATOR("String")
               if ( $expecting == OPERATOR );
             $in_quote                = 1;
             $type                    = 'Q';
-            $allowed_quote_modifiers = "";
+            $allowed_quote_modifiers = EMPTY_STRING;
         },
         '/' => sub {
             my $is_pattern;
@@ -2526,14 +2527,14 @@ EOM
             # code block or anonymous hash.  (The type of a paren
             # pair is the preceding token, such as 'if', 'else',
             # etc).
-            $container_type = "";
+            $container_type = EMPTY_STRING;
 
             # ATTRS: for a '{' following an attribute list, reset
             # things to look like we just saw the sub name
             if ( $statement_type =~ /^sub\b/ ) {
                 $last_nonblank_token = $statement_type;
                 $last_nonblank_type  = 'i';
-                $statement_type      = "";
+                $statement_type      = EMPTY_STRING;
             }
 
             # patch for SWITCH/CASE: hide these keywords from an immediately
@@ -2566,7 +2567,7 @@ EOM
                     }
                     else {
                         my $list =
-                          join( ' ', sort keys %is_blocktype_with_paren );
+                          join( SPACE, sort keys %is_blocktype_with_paren );
                         warning(
 "syntax error at ') {', didn't see one of: <<$list>>; If this code is okay try using the -xs flag\n"
                         );
@@ -2586,7 +2587,7 @@ EOM
                     );
 
                 }
-                $want_paren = "";
+                $want_paren = EMPTY_STRING;
             }
 
             # now identify which of the three possible types of
@@ -2650,7 +2651,7 @@ EOM
         },
         '}' => sub {
             $block_type = $brace_type[$brace_depth];
-            if ($block_type) { $statement_type = '' }
+            if ($block_type) { $statement_type = EMPTY_STRING }
             if ( defined( $brace_package[$brace_depth] ) ) {
                 $current_package = $brace_package[$brace_depth];
             }
@@ -3104,7 +3105,7 @@ EOM
 
                     # Note that we put a leading space on the here quote
                     # character indicate that it may be preceded by spaces
-                    $here_quote_character = " " . $here_quote_character;
+                    $here_quote_character = SPACE . $here_quote_character;
                     push @{$rhere_target_list},
                       [ $here_doc_target, $here_quote_character ];
                     $type = 'h';
@@ -3283,10 +3284,10 @@ EOM
         'tr' => '[cdsr]',
         'm'  => '[msixpodualngc]',
         'qr' => '[msixpodualn]',
-        'q'  => "",
-        'qq' => "",
-        'qw' => "",
-        'qx' => "",
+        'q'  => EMPTY_STRING,
+        'qq' => EMPTY_STRING,
+        'qw' => EMPTY_STRING,
+        'qx' => EMPTY_STRING,
     );
 
     # table showing how many quoted things to look for after quote operator..
@@ -3512,17 +3513,18 @@ EOM
           pre_tokenize( $input_line, $max_tokens_wanted );
 
         $max_token_index = scalar( @{$rtokens} ) - 1;
-        push( @{$rtokens}, ' ', ' ', ' ' );  # extra whitespace simplifies logic
+        push( @{$rtokens}, SPACE, SPACE, SPACE )
+          ;    # extra whitespace simplifies logic
         push( @{$rtoken_map},  0,   0,   0 );     # shouldn't be referenced
         push( @{$rtoken_type}, 'b', 'b', 'b' );
 
         # initialize for main loop
         if (0) { #<<< this is not necessary
         foreach my $ii ( 0 .. $max_token_index + 3 ) {
-            $routput_token_type->[$ii]     = "";
-            $routput_block_type->[$ii]     = "";
-            $routput_container_type->[$ii] = "";
-            $routput_type_sequence->[$ii]  = "";
+            $routput_token_type->[$ii]     = EMPTY_STRING;
+            $routput_block_type->[$ii]     = EMPTY_STRING;
+            $routput_container_type->[$ii] = EMPTY_STRING;
+            $routput_type_sequence->[$ii]  = EMPTY_STRING;
             $routput_indent_flag->[$ii]    = 0;
         }
         }
@@ -3573,11 +3575,11 @@ EOM
                 my $qs2 = $quoted_string_2;
 
                 # re-initialize for next search
-                $quote_character = '';
+                $quote_character = EMPTY_STRING;
                 $quote_pos       = 0;
                 $quote_type      = 'Q';
-                $quoted_string_1 = "";
-                $quoted_string_2 = "";
+                $quoted_string_1 = EMPTY_STRING;
+                $quoted_string_2 = EMPTY_STRING;
                 last if ( ++$i > $max_token_index );
 
                 # look for any modifiers
@@ -3663,7 +3665,7 @@ EOM
                     }
 
                     # re-initialize
-                    $allowed_quote_modifiers = "";
+                    $allowed_quote_modifiers = EMPTY_STRING;
                 }
             }
 
@@ -3736,11 +3738,11 @@ EOM
             $i_tok = $i;
 
             # re-initialize various flags for the next output token
-            $block_type     &&= "";
-            $container_type &&= "";
-            $type_sequence  &&= "";
+            $block_type     &&= EMPTY_STRING;
+            $container_type &&= EMPTY_STRING;
+            $type_sequence  &&= EMPTY_STRING;
             $indent_flag    &&= 0;
-            $prototype      &&= "";
+            $prototype      &&= EMPTY_STRING;
 
             # this pre-token will start an output token
             push( @{$routput_token_list}, $i_tok );
@@ -3784,7 +3786,7 @@ EOM
 
             # handle whitespace tokens..
             next if ( $type eq 'b' );
-            my $prev_tok  = $i > 0 ? $rtokens->[ $i - 1 ]     : ' ';
+            my $prev_tok  = $i > 0 ? $rtokens->[ $i - 1 ]     : SPACE;
             my $prev_type = $i > 0 ? $rtoken_type->[ $i - 1 ] : 'b';
 
             # Build larger tokens where possible, since we are not in a quote.
@@ -4629,9 +4631,9 @@ EOM
         my @nesting_blocks = ();   # string of block types leading to this depth
         my @nesting_lists  = ();   # string of list types leading to this depth
         my @ci_string = ();  # string needed to compute continuation indentation
-        my @container_environment = ();    # BLOCK or LIST
-        my $container_environment = '';
-        my $im                    = -1;    # previous $i value
+        my @container_environment = ();             # BLOCK or LIST
+        my $container_environment = EMPTY_STRING;
+        my $im                    = -1;             # previous $i value
         my $num;
 
         # Count the number of '1's in the string (previously sub ones_count)
@@ -4845,7 +4847,7 @@ EOM
                 $container_environment =
                     $nesting_block_flag ? 'BLOCK'
                   : $nesting_list_flag  ? 'LIST'
-                  :                       "";
+                  :                       EMPTY_STRING;
 
                 # if the difference between total nesting levels is not 1,
                 # there are intervening non-structural nesting types between
@@ -5100,7 +5102,7 @@ EOM
                 $container_environment =
                     $nesting_block_flag ? 'BLOCK'
                   : $nesting_list_flag  ? 'LIST'
-                  :                       "";
+                  :                       EMPTY_STRING;
                 $ci_string_i = $ci_string_sum + $in_statement_continuation;
                 $nesting_block_string_i = $nesting_block_string;
                 $nesting_list_string_i  = $nesting_list_string;
@@ -5112,7 +5114,7 @@ EOM
                 $container_environment =
                     $nesting_block_flag ? 'BLOCK'
                   : $nesting_list_flag  ? 'LIST'
-                  :                       "";
+                  :                       EMPTY_STRING;
 
                 # zero the continuation indentation at certain tokens so
                 # that they will be at the same level as its container.  For
@@ -5254,7 +5256,7 @@ EOM
         $tokenizer_self->[_in_attribute_list_] = $in_attribute_list;
         $tokenizer_self->[_in_quote_]          = $in_quote;
         $tokenizer_self->[_quote_target_] =
-          $in_quote ? matching_end_token($quote_character) : "";
+          $in_quote ? matching_end_token($quote_character) : EMPTY_STRING;
         $tokenizer_self->[_rhere_target_list_] = $rhere_target_list;
 
         $line_of_tokens->{_rtoken_type}            = \@token_type;
@@ -5380,7 +5382,7 @@ sub operator_expected {
 
     my ($rarg) = @_;
 
-    my $msg = "";
+    my $msg = EMPTY_STRING;
 
     ##############
     # Table lookup
@@ -5687,7 +5689,7 @@ sub code_block_type {
 
         # cannot start a code block within an anonymous hash
         else {
-            return "";
+            return EMPTY_STRING;
         }
     }
 
@@ -5750,7 +5752,7 @@ sub code_block_type {
                 || $last_nonblank_token eq 'unless' )
           )
         {
-            return "";
+            return EMPTY_STRING;
         }
         else {
             return $last_nonblank_token;
@@ -5785,7 +5787,7 @@ sub code_block_type {
 
         # check for syntax 'use MODULE LIST'
         # This fixes b1022 b1025 b1027 b1028 b1029 b1030 b1031
-        return "" if ( $statement_type eq 'use' );
+        return EMPTY_STRING if ( $statement_type eq 'use' );
 
         return decide_if_code_block( $i, $rtokens, $rtoken_type,
             $max_token_index );
@@ -5810,7 +5812,7 @@ sub code_block_type {
             return 't';    # (Not $paren_type)
         }
         else {
-            return "";
+            return EMPTY_STRING;
         }
     }
 
@@ -5822,7 +5824,7 @@ sub code_block_type {
 
     # anything else must be anonymous hash reference
     else {
-        return "";
+        return EMPTY_STRING;
     }
 }
 
@@ -5845,7 +5847,7 @@ sub decide_if_code_block {
     # Check for the common case of an empty anonymous hash reference:
     # Maybe something like sub { { } }
     if ( $next_nonblank_token eq '}' ) {
-        $code_block_type = "";
+        $code_block_type = EMPTY_STRING;
     }
 
     else {
@@ -5938,7 +5940,7 @@ sub decide_if_code_block {
                 || ( $pre_types[$j] eq '=' && $pre_types[ ++$j ] eq '>' )
               )
             {
-                $code_block_type = "";
+                $code_block_type = EMPTY_STRING;
             }
         }
 
@@ -5948,7 +5950,7 @@ sub decide_if_code_block {
             # If this brace follows a bareword, then append a space as a signal
             # to the formatter that this may not be a block brace.  To find the
             # corresponding code in Formatter.pm search for 'b1085'.
-            $code_block_type .= " " if ( $code_block_type =~ /^\w/ );
+            $code_block_type .= SPACE if ( $code_block_type =~ /^\w/ );
         }
     }
 
@@ -5972,7 +5974,7 @@ sub report_unexpected {
           make_numbered_line( $input_line_number, $input_line, $pos );
         $underline = write_on_underline( $underline, $pos - $offset, '^' );
 
-        my $trailer = "";
+        my $trailer = EMPTY_STRING;
         if ( ( $i_tok > 0 ) && ( $last_nonblank_i >= 0 ) ) {
             my $pos_prev = $rpretoken_map->[$last_nonblank_i];
             my $num;
@@ -6149,7 +6151,7 @@ sub increase_nesting_depth {
     # Fix part #1 for git82: save last token type for propagation of type 'Z'
     $nested_statement_type[$aa][ $current_depth[$aa] ] =
       [ $statement_type, $last_nonblank_type, $last_nonblank_token ];
-    $statement_type = "";
+    $statement_type = EMPTY_STRING;
     return ( $seqno, $indent );
 }
 
@@ -6239,7 +6241,7 @@ sub decrease_nesting_depth {
                     my ($ess);
 
                     if ( $diff == 1 || $diff == -1 ) {
-                        $ess = '';
+                        $ess = EMPTY_STRING;
                     }
                     else {
                         $ess = 's';
@@ -6395,7 +6397,7 @@ sub guess_if_pattern_or_conditional {
         # look for a possible ending ? on this line..
         my $in_quote        = 1;
         my $quote_depth     = 0;
-        my $quote_character = '';
+        my $quote_character = EMPTY_STRING;
         my $quote_pos       = 0;
         my $quoted_string;
         (
@@ -6506,7 +6508,7 @@ sub guess_if_pattern_or_division {
         # look for a possible ending / on this line..
         my $in_quote        = 1;
         my $quote_depth     = 0;
-        my $quote_character = '';
+        my $quote_character = EMPTY_STRING;
         my $quote_pos       = 0;
         my $quoted_string;
         (
@@ -6714,7 +6716,7 @@ sub scan_bare_identifier_do {
         # ($,%,@,*) including something like abc::def::ghi
         $type = 'w';
 
-        my $sub_name = "";
+        my $sub_name = EMPTY_STRING;
         if ( defined($2) ) { $sub_name = $2; }
         if ( defined($1) ) {
             $package = $1;
@@ -6905,7 +6907,7 @@ sub scan_id_do {
         $max_token_index )
       = @_;
     use constant DEBUG_NSCAN => 0;
-    my $type = '';
+    my $type = EMPTY_STRING;
     my ( $i_beg, $pos_beg );
 
     #print "NSCAN:entering i=$i, tok=$tok, type=$type, state=$id_scan_state\n";
@@ -6915,7 +6917,7 @@ sub scan_id_do {
     # on re-entry, start scanning at first token on the line
     if ($id_scan_state) {
         $i_beg = $i;
-        $type  = '';
+        $type  = EMPTY_STRING;
     }
 
     # on initial entry, start scanning just after type token
@@ -6974,12 +6976,12 @@ sub scan_id_do {
             ( $i, $tok, $type ) =
               do_scan_package( $input_line, $i, $i_beg, $tok, $type, $rtokens,
                 $rtoken_map, $max_token_index );
-            $id_scan_state = '';
+            $id_scan_state = EMPTY_STRING;
         }
 
         else {
             warning("invalid token in scan_id: $tok\n");
-            $id_scan_state = '';
+            $id_scan_state = EMPTY_STRING;
         }
     }
 
@@ -7149,13 +7151,13 @@ sub scan_identifier_do {
       = @_;
     use constant DEBUG_SCAN_ID => 0;
     my $i_begin   = $i;
-    my $type      = '';
+    my $type      = EMPTY_STRING;
     my $tok_begin = $rtokens->[$i_begin];
     if ( $tok_begin eq ':' ) { $tok_begin = '::' }
     my $id_scan_state_begin = $id_scan_state;
     my $identifier_begin    = $identifier;
     my $tok                 = $tok_begin;
-    my $message             = "";
+    my $message             = EMPTY_STRING;
     my $tok_is_blank;    # a flag to speed things up
 
     my $in_prototype_or_signature =
@@ -7196,7 +7198,7 @@ sub scan_identifier_do {
         elsif ( $tok eq 'sub' or $tok eq 'package' ) {
             $saw_alpha     = 0;     # 'sub' is considered type info here
             $id_scan_state = '$';
-            $identifier .= ' ';     # need a space to separate sub from sub name
+            $identifier .= SPACE;   # need a space to separate sub from sub name
         }
         elsif ( $tok eq '::' ) {
             $id_scan_state = 'A';
@@ -7218,7 +7220,7 @@ sub scan_identifier_do {
                 warning($msg);
                 $tokenizer_self->[_in_error_] = 1;
             }
-            $id_scan_state = '';
+            $id_scan_state = EMPTY_STRING;
             goto RETURN;
         }
         $saw_type = !$saw_alpha;
@@ -7261,7 +7263,7 @@ sub scan_identifier_do {
                 # we've got a punctuation variable if end of line (punct.t)
                 if ( $i == $max_token_index ) {
                     $type          = 'i';
-                    $id_scan_state = '';
+                    $id_scan_state = EMPTY_STRING;
                     last;
                 }
             }
@@ -7322,7 +7324,7 @@ sub scan_identifier_do {
                     elsif ( $id_scan_state eq '$' ) { $type = 't' }
                     else                            { $type = 'i' }
                     $i             = $i_save;
-                    $id_scan_state = '';
+                    $id_scan_state = EMPTY_STRING;
                     last;
                 }
             }
@@ -7345,16 +7347,18 @@ sub scan_identifier_do {
                     my $next1 = $rtokens->[ $i + 1 ];
                     $identifier .= $tok . $next1 . $next2;
                     $i += 2;
-                    $id_scan_state = '';
+                    $id_scan_state = EMPTY_STRING;
                     last;
                 }
 
                 # skip something like ${xxx} or ->{
-                $id_scan_state = '';
+                $id_scan_state = EMPTY_STRING;
 
                 # if this is the first token of a line, any tokens for this
                 # identifier have already been accumulated
-                if ( $identifier eq '$' || $i == 0 ) { $identifier = ''; }
+                if ( $identifier eq '$' || $i == 0 ) {
+                    $identifier = EMPTY_STRING;
+                }
                 $i = $i_save;
                 last;
             }
@@ -7368,7 +7372,7 @@ sub scan_identifier_do {
                 if ( $identifier =~ /^[\$\%\*\&\@]/ ) {
 
                     if ( length($identifier) > 1 ) {
-                        $id_scan_state = '';
+                        $id_scan_state = EMPTY_STRING;
                         $i             = $i_save;
                         $type          = 'i';    # probably punctuation variable
                         last;
@@ -7427,19 +7431,20 @@ sub scan_identifier_do {
 
                         # If pretoken $next1 is more than one character long,
                         # set a flag indicating that it needs to be split.
-                        $id_scan_state = ( length($next1) > 1 ) ? '^' : "";
+                        $id_scan_state =
+                          ( length($next1) > 1 ) ? '^' : EMPTY_STRING;
                         last;
                     }
                     else {
 
                         # it is just $^
                         # Simple test case (c065): '$aa=$^if($bb)';
-                        $id_scan_state = "";
+                        $id_scan_state = EMPTY_STRING;
                         last;
                     }
                 }
                 else {
-                    $id_scan_state = '';
+                    $id_scan_state = EMPTY_STRING;
                     $i             = $i_save;
                     last;    # c106
                 }
@@ -7457,8 +7462,8 @@ sub scan_identifier_do {
                     # '$' which will have been previously marked type 't'
                     # rather than 'i'.
                     if ( $i == $i_begin ) {
-                        $identifier = "";
-                        $type       = "";
+                        $identifier = EMPTY_STRING;
+                        $type       = EMPTY_STRING;
                     }
 
                     # at a # we have to mark as type 't' because more may
@@ -7472,7 +7477,7 @@ sub scan_identifier_do {
                         }
                         $i = $i_save;
                     }
-                    $id_scan_state = '';
+                    $id_scan_state = EMPTY_STRING;
                     last;
                 }
 
@@ -7522,9 +7527,11 @@ sub scan_identifier_do {
                 }
                 else {
                     $i = $i_save;
-                    if ( length($identifier) == 1 ) { $identifier = ''; }
+                    if ( length($identifier) == 1 ) {
+                        $identifier = EMPTY_STRING;
+                    }
                 }
-                $id_scan_state = '';
+                $id_scan_state = EMPTY_STRING;
                 last;
             }
         }
@@ -7556,7 +7563,7 @@ sub scan_identifier_do {
                 $identifier .= $tok;
             }
             else {
-                $id_scan_state = '';
+                $id_scan_state = EMPTY_STRING;
                 $i             = $i_save;
                 last;
             }
@@ -7582,7 +7589,7 @@ sub scan_identifier_do {
             elsif ( $tok eq "'" && $allow_tick ) {    # tick
 
                 if ( $is_keyword{$identifier} ) {
-                    $id_scan_state = '';              # that's all
+                    $id_scan_state = EMPTY_STRING;    # that's all
                     $i             = $i_save;
                 }
                 else {
@@ -7598,7 +7605,7 @@ sub scan_identifier_do {
                 $identifier .= $tok;
             }
             else {
-                $id_scan_state = '';        # that's all
+                $id_scan_state = EMPTY_STRING;    # that's all
                 $i             = $i_save;
                 last;
             }
@@ -7619,7 +7626,7 @@ sub scan_identifier_do {
                 $tok_is_blank = 1;
             }
             else {
-                $id_scan_state = '';        # that's all - no prototype
+                $id_scan_state = EMPTY_STRING;    # that's all - no prototype
                 $i             = $i_save;
                 last;
             }
@@ -7635,7 +7642,7 @@ sub scan_identifier_do {
 
             if ( $tok eq ')' ) {    # got it
                 $identifier .= $tok;
-                $id_scan_state = '';    # all done
+                $id_scan_state = EMPTY_STRING;    # all done
                 last;
             }
             elsif ( $tok =~ /^[\s\$\%\\\*\@\&\;]/ ) {
@@ -7678,9 +7685,11 @@ sub scan_identifier_do {
                 $identifier .= $tok;
             }
             elsif ( $tok eq '{' ) {
-                if ( $identifier eq '&' || $i == 0 ) { $identifier = ''; }
+                if ( $identifier eq '&' || $i == 0 ) {
+                    $identifier = EMPTY_STRING;
+                }
                 $i             = $i_save;
-                $id_scan_state = '';
+                $id_scan_state = EMPTY_STRING;
                 last;
             }
             elsif ( $tok eq '^' ) {
@@ -7701,17 +7710,18 @@ sub scan_identifier_do {
 
                         # If pretoken $next1 is more than one character long,
                         # set a flag indicating that it needs to be split.
-                        $id_scan_state = ( length($next1) > 1 ) ? '^' : "";
+                        $id_scan_state =
+                          ( length($next1) > 1 ) ? '^' : EMPTY_STRING;
                     }
                     else {
 
                         # it is &^
-                        $id_scan_state = "";
+                        $id_scan_state = EMPTY_STRING;
                     }
                     last;
                 }
                 else {
-                    $identifier = '';
+                    $identifier = EMPTY_STRING;
                     $i          = $i_save;
                 }
                 last;
@@ -7737,11 +7747,11 @@ sub scan_identifier_do {
                     $identifier .= $tok;
                 }
                 else {
-                    $identifier = '';
+                    $identifier = EMPTY_STRING;
                     $i          = $i_save;
                     $type       = '&';
                 }
-                $id_scan_state = '';
+                $id_scan_state = EMPTY_STRING;
                 last;
             }
         }
@@ -7751,7 +7761,7 @@ sub scan_identifier_do {
         ######################
 
         else {    # can get here due to error in initialization
-            $id_scan_state = '';
+            $id_scan_state = EMPTY_STRING;
             $i             = $i_save;
             last;
         }
@@ -7764,12 +7774,12 @@ sub scan_identifier_do {
     # once we enter the actual identifier, it may not extend beyond
     # the end of the current line
     if ( $id_scan_state =~ /^[A\:\(\)]/ ) {
-        $id_scan_state = '';
+        $id_scan_state = EMPTY_STRING;
     }
 
     # Patch: the deprecated variable $# does not combine with anything on the
     # next line.
-    if ( $identifier eq '$#' ) { $id_scan_state = '' }
+    if ( $identifier eq '$#' ) { $id_scan_state = EMPTY_STRING }
 
     if ( $i < 0 ) { $i = 0 }
 
@@ -7824,7 +7834,7 @@ sub scan_identifier_do {
             }
         }
         else {
-            $type = '';
+            $type = EMPTY_STRING;
         }    # this can happen on a restart
     }
 
@@ -7868,8 +7878,8 @@ sub scan_identifier_do {
 
     # initialize subname each time a new 'sub' keyword is encountered
     sub initialize_subname {
-        $package_saved = "";
-        $subname_saved = "";
+        $package_saved = EMPTY_STRING;
+        $subname_saved = EMPTY_STRING;
         return;
     }
 
@@ -7944,7 +7954,7 @@ sub scan_identifier_do {
           : $tok eq '('         ? PAREN_CALL
           :                       SUB_CALL;
 
-        $id_scan_state = "";    # normally we get everything in one call
+        $id_scan_state = EMPTY_STRING;  # normally we get everything in one call
         my $subname = $subname_saved;
         my $package = $package_saved;
         my $proto   = undef;
@@ -8174,7 +8184,7 @@ sub scan_identifier_do {
                 }
             }
             elsif ($next_nonblank_token) {    # EOF technically ok
-                $subname = "" unless defined($subname);
+                $subname = EMPTY_STRING unless defined($subname);
                 warning(
 "expecting ':' or ';' or '{' after definition or declaration of sub '$subname' but saw '$next_nonblank_token'\n"
                 );
@@ -8209,11 +8219,11 @@ sub find_next_nonblank_token {
     }
 
     my $next_nonblank_token = $rtokens->[ ++$i ];
-    return ( " ", $i ) unless defined($next_nonblank_token);
+    return ( SPACE, $i ) unless defined($next_nonblank_token);
 
     if ( $next_nonblank_token =~ /^\s*$/ ) {
         $next_nonblank_token = $rtokens->[ ++$i ];
-        return ( " ", $i ) unless defined($next_nonblank_token);
+        return ( SPACE, $i ) unless defined($next_nonblank_token);
     }
     return ( $next_nonblank_token, $i );
 }
@@ -8234,7 +8244,7 @@ sub find_next_noncomment_type {
           find_next_nonblank_token( $i_next, $rtokens, $max_token_index );
     }
 
-    goto RETURN if ( !$next_nonblank_token || $next_nonblank_token eq " " );
+    goto RETURN if ( !$next_nonblank_token || $next_nonblank_token eq SPACE );
 
     # check for possible a digraph
     goto RETURN if ( !defined( $rtokens->[ $i_next + 1 ] ) );
@@ -8357,7 +8367,7 @@ sub find_next_nonblank_token_on_this_line {
         }
     }
     else {
-        $next_nonblank_token = "";
+        $next_nonblank_token = EMPTY_STRING;
     }
     return ( $next_nonblank_token, $i );
 }
@@ -8718,8 +8728,8 @@ sub find_here_doc {
     my ( $expecting, $i, $rtokens, $rtoken_map, $max_token_index ) = @_;
     my $ibeg                 = $i;
     my $found_target         = 0;
-    my $here_doc_target      = '';
-    my $here_quote_character = '';
+    my $here_doc_target      = EMPTY_STRING;
+    my $here_quote_character = EMPTY_STRING;
     my $saw_error            = 0;
     my ( $next_nonblank_token, $i_next_nonblank, $next_token );
     $next_token = $rtokens->[ $i + 1 ];
@@ -8848,7 +8858,7 @@ sub do_quote {
         $quoted_string_2 .= $quoted_string;
         if ( $in_quote == 1 ) {
             if ( $quote_character =~ /[\{\[\<\(]/ ) { $i++; }
-            $quote_character = '';
+            $quote_character = EMPTY_STRING;
         }
         else {
             $quoted_string_2 .= "\n";
@@ -8894,7 +8904,7 @@ sub follow_quoted_string {
       = @_;
     my ( $tok, $end_tok );
     my $i             = $i_beg - 1;
-    my $quoted_string = "";
+    my $quoted_string = EMPTY_STRING;
 
     0 && do {
         print STDOUT
@@ -9117,7 +9127,7 @@ sub make_numbered_line {
     my $numbered_line = sprintf( "%d: ", $lineno );
     $offset -= length($numbered_line);
     $numbered_line .= $str;
-    my $underline = " " x length($numbered_line);
+    my $underline = SPACE x length($numbered_line);
     return ( $offset, $numbered_line, $underline );
 }
 
index 3de4badc5b1a5dd6d34004f6d2f210d59b8b6247..83af9b3aa90149782a0d3e3c51d6d2483de03d20 100644 (file)
@@ -7,7 +7,9 @@ our $VERSION = '20220217.04';
 use Perl::Tidy::VerticalAligner::Alignment;
 use Perl::Tidy::VerticalAligner::Line;
 
-use constant DEVEL_MODE => 0;
+use constant DEVEL_MODE   => 0;
+use constant EMPTY_STRING => q{};
+use constant SPACE        => q{ };
 
 # The Perl::Tidy::VerticalAligner package collects output lines and
 # attempts to line up certain common tokens, such as => and #, which are
@@ -287,7 +289,7 @@ sub new {
     # Batch of lines being collected
     $self->[_rgroup_lines_]                = [];
     $self->[_group_level_]                 = 0;
-    $self->[_group_type_]                  = "";
+    $self->[_group_type_]                  = EMPTY_STRING;
     $self->[_group_maximum_line_length_]   = undef;
     $self->[_zero_count_]                  = 0;
     $self->[_comment_leading_space_count_] = 0;
@@ -335,7 +337,7 @@ sub initialize_for_new_group {
     my ($self) = @_;
 
     $self->[_rgroup_lines_]                = [];
-    $self->[_group_type_]                  = "";
+    $self->[_group_type_]                  = EMPTY_STRING;
     $self->[_zero_count_]                  = 0;
     $self->[_comment_leading_space_count_] = 0;
     $self->[_last_leading_space_count_]    = 0;
@@ -375,7 +377,7 @@ sub write_diagnostics {
     }
 
     sub get_input_stream_name {
-        my $input_stream_name = "";
+        my $input_stream_name = EMPTY_STRING;
         if ($logger_object) {
             $input_stream_name = $logger_object->get_input_stream_name();
         }
@@ -645,7 +647,7 @@ sub valign_input {
     # --------------------------------------------------------------------
     # Collect outdentable block COMMENTS
     # --------------------------------------------------------------------
-    my $is_blank_line = "";
+    my $is_blank_line = EMPTY_STRING;
     if ( $self->[_group_type_] eq 'COMMENT' ) {
         if (
             (
@@ -771,7 +773,7 @@ sub valign_input {
     if ( ( $jmax == 0 ) || ( $rtokens->[ $jmax - 1 ] ne '#' ) ) {
         $jmax += 1;
         $rtokens->[ $jmax - 1 ]  = '#';
-        $rfields->[$jmax]        = '';
+        $rfields->[$jmax]        = EMPTY_STRING;
         $rfield_lengths->[$jmax] = 0;
         $rpatterns->[$jmax]      = '#';
     }
@@ -790,7 +792,7 @@ sub valign_input {
             leading_space_count       => $leading_space_count,
             outdent_long_lines        => $outdent_long_lines,
             list_seqno                => $list_seqno,
-            list_type                 => "",
+            list_type                 => EMPTY_STRING,
             is_hanging_side_comment   => $is_hanging_side_comment,
             rvertical_tightness_flags => $rvertical_tightness_flags,
             is_terminal_ternary       => $is_terminal_ternary,
@@ -882,10 +884,10 @@ sub join_hanging_comment {
     $rtokens->[ $jmax - 1 ]   = $rtokens->[0];
     $rpatterns->[ $jmax - 1 ] = $rpatterns->[0];
     foreach my $j ( 1 .. $jmax - 1 ) {
-        $rfields->[$j]         = '';
+        $rfields->[$j]         = EMPTY_STRING;
         $rfield_lengths->[$j]  = 0;
-        $rtokens->[ $j - 1 ]   = "";
-        $rpatterns->[ $j - 1 ] = "";
+        $rtokens->[ $j - 1 ]   = EMPTY_STRING;
+        $rpatterns->[ $j - 1 ] = EMPTY_STRING;
     }
     return 1;
 }
@@ -921,7 +923,7 @@ sub join_hanging_comment {
                 ( $raw_tok, $lev, $tag, $tok_count ) =
                   decode_alignment_token( $rtokens->[$_] );
                 if ( !$is_comma_token{$raw_tok} ) {
-                    $list_type = "";
+                    $list_type = EMPTY_STRING;
                     last;
                 }
             }
@@ -967,7 +969,7 @@ sub fix_terminal_ternary {
     # look for the question mark after the :
     my ($jquestion);
     my $depth_question;
-    my $pad        = "";
+    my $pad        = EMPTY_STRING;
     my $pad_length = 0;
     foreach my $j ( 0 .. $maximum_field_index - 1 ) {
         my $tok = $rtokens_old->[$j];
@@ -981,7 +983,7 @@ sub fix_terminal_ternary {
             $jquestion = $j;
             if ( $rfields_old->[ $j + 1 ] =~ /^(\?\s*)/ ) {
                 $pad_length = length($1);
-                $pad        = " " x $pad_length;
+                $pad        = SPACE x $pad_length;
             }
             else {
                 return;    # shouldn't happen
@@ -1044,8 +1046,8 @@ sub fix_terminal_ternary {
             unshift( @patterns, @{$rpatterns_old}[ 0 .. $jquestion ] );
 
             # insert appropriate number of empty fields
-            splice( @fields,        1, 0, ('') x $jadd ) if $jadd;
-            splice( @field_lengths, 1, 0, (0) x $jadd )  if $jadd;
+            splice( @fields,        1, 0, (EMPTY_STRING) x $jadd ) if $jadd;
+            splice( @field_lengths, 1, 0, (0) x $jadd )            if $jadd;
         }
 
         # handle sub-case of first field just equal to leading colon.
@@ -1068,8 +1070,8 @@ sub fix_terminal_ternary {
             # leading token and inserting appropriate number of empty fields
             splice( @tokens,   0, 1, @{$rtokens_old}[ 0 .. $jquestion ] );
             splice( @patterns, 1, 0, @{$rpatterns_old}[ 1 .. $jquestion ] );
-            splice( @fields,        1, 0, ('') x $jadd ) if $jadd;
-            splice( @field_lengths, 1, 0, (0) x $jadd )  if $jadd;
+            splice( @fields,        1, 0, (EMPTY_STRING) x $jadd ) if $jadd;
+            splice( @field_lengths, 1, 0, (0) x $jadd )            if $jadd;
         }
     }
 
@@ -1088,8 +1090,8 @@ sub fix_terminal_ternary {
         $jadd             = $jquestion + 1;
         $fields[0]        = $pad . $fields[0];
         $field_lengths[0] = $pad_length + $field_lengths[0];
-        splice( @fields,        0, 0, ('') x $jadd ) if $jadd;
-        splice( @field_lengths, 0, 0, (0) x $jadd )  if $jadd;
+        splice( @fields,        0, 0, (EMPTY_STRING) x $jadd ) if $jadd;
+        splice( @field_lengths, 0, 0, (0) x $jadd )            if $jadd;
     }
 
     EXPLAIN_TERNARY && do {
@@ -1173,7 +1175,7 @@ sub fix_terminal_else {
     my $jadd = $jbrace - $jparen;
     splice( @{$rtokens},   0, 0, @{$rtokens_old}[ $jparen .. $jbrace - 1 ] );
     splice( @{$rpatterns}, 1, 0, @{$rpatterns_old}[ $jparen + 1 .. $jbrace ] );
-    splice( @{$rfields},        1, 0, ('') x $jadd );
+    splice( @{$rfields},        1, 0, (EMPTY_STRING) x $jadd );
     splice( @{$rfield_lengths}, 1, 0, (0) x $jadd );
 
     # force a flush after this line if it does not follow a case
@@ -1210,7 +1212,7 @@ sub check_match {
     my $imax_align = -1;
 
     # variable $GoToMsg explains reason for no match, for debugging
-    my $GoToMsg = "";
+    my $GoToMsg = EMPTY_STRING;
     use constant EXPLAIN_CHECK_MATCH => 0;
 
     # This is a flag for testing alignment by sub sweep_left_to_right only.
@@ -2444,7 +2446,7 @@ EOM
         # An existing list will still be a list but with possibly different
         # leading token
         my $old_list_type = $line_obj->get_list_type();
-        my $new_list_type = "";
+        my $new_list_type = EMPTY_STRING;
         if ( $rtokens_new->[0] =~ /^(=>|,)/ ) {
             $new_list_type = $rtokens_new->[0];
         }
@@ -2506,7 +2508,7 @@ EOM
             return @{ $decoded_token{$tok} };
         }
 
-        my ( $raw_tok, $lev, $tag, $tok_count ) = ( $tok, 0, "", 1 );
+        my ( $raw_tok, $lev, $tag, $tok_count ) = ( $tok, 0, EMPTY_STRING, 1 );
         if ( $tok =~ /^(\D+)(\d+)([^\.]*)(\.(\d+))?$/ ) {
             $raw_tok   = $1;
             $lev       = $2;
@@ -2797,7 +2799,7 @@ EOM
                 my $delete_above_level;
                 my $deleted_assignment_token;
 
-                my $saw_dividing_token = "";
+                my $saw_dividing_token = EMPTY_STRING;
                 $saw_large_group ||= $nlines > 2 && $imax > 1;
 
                 # Loop over all alignment tokens
@@ -3190,7 +3192,7 @@ sub match_line_pairs {
         #   2 = no match, and lines do not match at all
 
         my ( $tok, $tok_m, $pat, $pat_m, $pad ) = @_;
-        my $GoToMsg     = "";
+        my $GoToMsg     = EMPTY_STRING;
         my $return_code = 1;
 
         my ( $alignment_token, $lev, $tag, $tok_count ) =
@@ -3456,7 +3458,7 @@ sub get_line_token_info {
         my $rtokens = $line->get_rtokens();
         my $i       = -1;
         my ( $lev_min, $lev_max );
-        my $token_pattern_max = "";
+        my $token_pattern_max = EMPTY_STRING;
         my %saw_level;
         my $is_monotonic = 1;
 
@@ -3517,7 +3519,7 @@ sub get_line_token_info {
             $lev_min                     = -1;
             $lev_max                     = -1;
             $levs[0]                     = -1;
-            $rtoken_patterns->{$lev_min} = "";
+            $rtoken_patterns->{$lev_min} = EMPTY_STRING;
             $rtoken_indexes->{$lev_min}  = [];
         }
 
@@ -4050,8 +4052,8 @@ sub Dump_tree_groups {
         # it seems that the an alignment would look bad.
         my $max_pad            = 0;
         my $saw_good_alignment = 0;
-        my $saw_if_or;        # if we saw an 'if' or 'or' at group level
-        my $raw_tokb = "";    # first token seen at group level
+        my $saw_if_or;                # if we saw an 'if' or 'or' at group level
+        my $raw_tokb = EMPTY_STRING;  # first token seen at group level
         my $jfirst_bad;
         my $line_ending_fat_comma;    # is last token just a '=>' ?
         my $j0_eq_pad;
@@ -4737,7 +4739,7 @@ sub valign_output_step_A {
         # only add padding when we have a finite field;
         # this avoids extra terminal spaces if we have empty fields
         if ( $rfield_lengths->[$j] > 0 ) {
-            $str .= ' ' x $total_pad_count;
+            $str .= SPACE x $total_pad_count;
             $str_len += $total_pad_count;
             $total_pad_count = 0;
             $str .= $rfields->[$j];
@@ -4866,7 +4868,7 @@ sub get_output_line_number {
     sub initialize_step_B_cache {
 
         # valign_output_step_B cache:
-        $cached_line_text                = "";
+        $cached_line_text                = EMPTY_STRING;
         $cached_line_text_length         = 0;
         $cached_line_type                = 0;
         $cached_line_opening_flag        = 0;
@@ -4874,14 +4876,14 @@ sub get_output_line_number {
         $cached_seqno                    = 0;
         $cached_line_valid               = 0;
         $cached_line_leading_space_count = 0;
-        $cached_seqno_string             = "";
+        $cached_seqno_string             = EMPTY_STRING;
         $cached_line_Kend                = undef;
         $cached_line_maximum_length      = undef;
 
         # These vars hold a string of sequence numbers joined together used by
         # the cache
-        $seqno_string               = "";
-        $last_nonblank_seqno_string = "";
+        $seqno_string               = EMPTY_STRING;
+        $last_nonblank_seqno_string = EMPTY_STRING;
         return;
     }
 
@@ -4899,9 +4901,9 @@ sub get_output_line_number {
                 $cached_line_Kend,
             );
             $cached_line_type           = 0;
-            $cached_line_text           = "";
+            $cached_line_text           = EMPTY_STRING;
             $cached_line_text_length    = 0;
-            $cached_seqno_string        = "";
+            $cached_seqno_string        = EMPTY_STRING;
             $cached_line_Kend           = undef;
             $cached_line_maximum_length = undef;
         }
@@ -4965,7 +4967,9 @@ sub get_output_line_number {
         # later by entabbing, so we have to keep track of any changes
         # to the leading_space_count from here on.
         my $leading_string =
-          $leading_space_count > 0 ? ( ' ' x $leading_space_count ) : "";
+          $leading_space_count > 0
+          ? ( SPACE x $leading_space_count )
+          : EMPTY_STRING;
         my $leading_string_length = length($leading_string);
 
         # Unpack any recombination data; it was packed by
@@ -5063,7 +5067,7 @@ sub get_output_line_number {
 
                 if ( $gap >= 0 && defined($seqno_beg) ) {
                     $maximum_line_length   = $cached_line_maximum_length;
-                    $leading_string        = $cached_line_text . ' ' x $gap;
+                    $leading_string        = $cached_line_text . SPACE x $gap;
                     $leading_string_length = $cached_line_text_length + $gap;
                     $leading_space_count   = $cached_line_leading_space_count;
                     $seqno_string = $cached_seqno_string . ':' . $seqno_beg;
@@ -5085,7 +5089,7 @@ sub get_output_line_number {
             # Handle cached line ending in CLOSING tokens
             else {
                 my $test_line =
-                  $cached_line_text . ' ' x $cached_line_closing_flag . $str;
+                  $cached_line_text . SPACE x $cached_line_closing_flag . $str;
                 my $test_line_length =
                   $cached_line_text_length +
                   $cached_line_closing_flag +
@@ -5214,7 +5218,7 @@ sub get_output_line_number {
                     # Change the args to look like we received the combined line
                     $str                   = $test_line;
                     $str_length            = $test_line_length;
-                    $leading_string        = "";
+                    $leading_string        = EMPTY_STRING;
                     $leading_string_length = 0;
                     $leading_space_count   = $cached_line_leading_space_count;
                     $level                 = $last_level_written;
@@ -5234,7 +5238,7 @@ sub get_output_line_number {
             }
         }
         $cached_line_type           = 0;
-        $cached_line_text           = "";
+        $cached_line_text           = EMPTY_STRING;
         $cached_line_text_length    = 0;
         $cached_line_Kend           = undef;
         $cached_line_maximum_length = undef;
@@ -5301,7 +5305,7 @@ sub get_output_line_number {
 
     sub initialize_valign_buffer {
         @valign_buffer         = ();
-        $valign_buffer_filling = "";
+        $valign_buffer_filling = EMPTY_STRING;
         return;
     }
 
@@ -5313,7 +5317,7 @@ sub get_output_line_number {
             }
             @valign_buffer = ();
         }
-        $valign_buffer_filling = "";
+        $valign_buffer_filling = EMPTY_STRING;
         return;
     }
 
@@ -5465,7 +5469,7 @@ sub valign_output_step_D {
               $leading_space_count % $rOpts_entab_leading_whitespace;
             my $tab_count =
               int( $leading_space_count / $rOpts_entab_leading_whitespace );
-            my $leading_string = "\t" x $tab_count . ' ' x $space_count;
+            my $leading_string = "\t" x $tab_count . SPACE x $space_count;
             if ( $line =~ /^\s{$leading_space_count,$leading_space_count}/ ) {
                 substr( $line, 0, $leading_space_count ) = $leading_string;
             }
@@ -5496,10 +5500,10 @@ sub valign_output_step_D {
 "Error entabbing in valign_output_step_D: for level=$level count=$leading_space_count\n"
                       );
                 }
-                $leading_string = ( ' ' x $leading_space_count );
+                $leading_string = ( SPACE x $leading_space_count );
             }
             else {
-                $leading_string .= ( ' ' x $space_count );
+                $leading_string .= ( SPACE x $space_count );
             }
             if ( $line =~ /^\s{$leading_space_count,$leading_space_count}/ ) {
                 substr( $line, 0, $leading_space_count ) = $leading_string;
@@ -5538,7 +5542,7 @@ sub valign_output_step_D {
         # Handle case of zero whitespace, which includes multi-line quotes
         # (which may have a finite level; this prevents tab problems)
         if ( $leading_whitespace_count <= 0 ) {
-            return "";
+            return EMPTY_STRING;
         }
 
         # look for previous result
@@ -5558,7 +5562,7 @@ sub valign_output_step_D {
         if ( !( $rOpts_tabs || $rOpts_entab_leading_whitespace )
             || $rOpts_indent_columns <= 0 )
         {
-            $leading_string = ( ' ' x $leading_whitespace_count );
+            $leading_string = ( SPACE x $leading_whitespace_count );
         }
 
         # Handle entab option
@@ -5567,7 +5571,7 @@ sub valign_output_step_D {
               $leading_whitespace_count % $rOpts_entab_leading_whitespace;
             my $tab_count = int(
                 $leading_whitespace_count / $rOpts_entab_leading_whitespace );
-            $leading_string = "\t" x $tab_count . ' ' x $space_count;
+            $leading_string = "\t" x $tab_count . SPACE x $space_count;
         }
 
         # Handle option of one tab per level
@@ -5584,10 +5588,10 @@ sub valign_output_step_D {
                   );
 
                 # -- skip entabbing
-                $leading_string = ( ' ' x $leading_whitespace_count );
+                $leading_string = ( SPACE x $leading_whitespace_count );
             }
             else {
-                $leading_string .= ( ' ' x $space_count );
+                $leading_string .= ( SPACE x $space_count );
             }
         }
         $leading_string_cache[$leading_whitespace_count] = $leading_string;