if (@grep_aliases) {
- @{is_sort_map_grep}{@grep_aliases} = (1) x scalar(@grep_aliases);
+ @is_sort_map_grep{@grep_aliases} = (1) x scalar(@grep_aliases);
if ( $want_one_line_block{'grep'} ) {
- @{want_one_line_block}{@grep_aliases} = (1) x scalar(@grep_aliases);
+ @want_one_line_block{@grep_aliases} = (1) x scalar(@grep_aliases);
}
}
# variables, like $^W: (issue c066, c068).
@q =
qw{ ? A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ };
- @{is_special_variable_char}{@q} = (1) x scalar(@q);
+ @is_special_variable_char{@q} = (1) x scalar(@q);
@q = qw( 0 1 2 3 4 5 6 7 8 9 );
@is_digit_char{@q} = (1) x scalar(@q);
BEGIN {
my @q = qw( for foreach while do until );
- @{is_loop_type}{@q} = (1) x scalar(@q);
+ @is_loop_type{@q} = (1) x scalar(@q);
}
sub find_level_info {
$rOpts_dump_block_types =~ s/\s+$//;
my @list = split /\s+/, $rOpts_dump_block_types;
my %dump_block_types;
- @{dump_block_types}{@list} = (1) x scalar(@list);
+ @dump_block_types{@list} = (1) x scalar(@list);
# Get level variation info for code blocks
my $rlevel_info = $self->find_level_info();
#-------------------------------------------------------------
# sub to find the next opening brace seqno of an if-elsif- chain
#-------------------------------------------------------------
- my $next_if_chain_seqno = sub {
- my ($KK) = @_;
+ my $push_next_if_chain = sub {
+ my ( $KK, $rpopped_vars ) = @_;
# Given:
# $KK = index of a closing block brace of if/unless/elsif chain
- # Return:
- # $seqno_block = sequence number of next opening block in the chain,
- # nothing if chain ends
+ # $rpopped_vars = values just popped off the stack
+ # Task:
+ # - do nothing if chain ends, or
+ # - push $rpopped_vars onto the next block in the chain
+
+ # $seqno_block = sequence number of next opening block in the chain,
my $seqno_block;
my $K_n = $self->K_next_code($KK);
return unless ($K_n);
else {
# chain ends if no elsif/else block
}
- return $seqno_block;
+
+ if ( $seqno_block
+ && $rblock_type_of_seqno->{$seqno_block} )
+ {
+ $push_block_stack->( $seqno_block, $rpopped_vars );
+ }
+ return;
};
my $scan_braced_id = sub {
$stack_item = pop @{$rblock_stack};
$rpopped_vars = $stack_item->{rvars};
- # Check unused vars except for vars in an
- # if-chain control layer
+ # Check unused vars
+ # - except for vars in an if-chain control layer
+ # because they are involved in logic
if ( $check_unused
&& $rpopped_vars
&& !$is_if_unless_elsif_else{$block_type} )
# propagate control layer along if chain
if ( $is_if_unless_elsif{$block_type} ) {
- my $seqno_blk = $next_if_chain_seqno->($KK);
- if ( $seqno_blk
- && $rblock_type_of_seqno->{$seqno_blk} )
- {
- $push_block_stack->(
- $seqno_blk, $rpopped_vars
- );
- }
+ $push_next_if_chain->( $KK, $rpopped_vars );
}
}
}
$excluded_names =~ s/^\s+//;
$excluded_names =~ s/\s+$//;
my @xl = split /\s+/, $excluded_names;
- @{is_excluded_name}{@xl} = (1) x scalar(@xl);
+ @is_excluded_name{@xl} = (1) x scalar(@xl);
}
foreach my $item ( @{$rwarnings} ) {
# added 'U' to fix cases b1125 b1126 b1127
my @q = qw(w U);
- @{wU}{@q} = (1) x scalar(@q);
+ @wU{@q} = (1) x scalar(@q);
@q = qw(w i q Q G C Z);
- @{wiq}{@q} = (1) x scalar(@q);
+ @wiq{@q} = (1) x scalar(@q);
@q = qw(w i t P S); # Fix for c250: added new types 'P', 'S', formerly 'i'
- @{is_witPS}{@q} = (1) x scalar(@q);
+ @is_witPS{@q} = (1) x scalar(@q);
@q = qw($ & % * @);
- @{is_sigil}{@q} = (1) x scalar(@q);
+ @is_sigil{@q} = (1) x scalar(@q);
# Parens following these keywords will not be marked as lists. Note that
# 'for' is not included and is handled separately, by including 'f' in the
# these types do not 'like' to be separated from a following paren
@q = qw(w i q Q G C Z U);
- @{has_tight_paren}{@q} = (1) x scalar(@q);
+ @has_tight_paren{@q} = (1) x scalar(@q);
} ## end BEGIN
use constant DEBUG_WELD => 0;
if ( $CODE_type eq 'BL' ) {
if ( $ibeg >= 0 ) {
$iend = $i;
- push @{iblanks}, $i;
+ push @iblanks, $i;
# propagate current subgroup token
my $tok = $group[-1]->[1];
# b1450: old breaks at 'eq' and related operators are poor
my @q = qw(== <= >= !=);
- @{poor_types}{@q} = (1) x scalar(@q);
- @{poor_next_types}{@q} = (1) x scalar(@q);
+ @poor_types{@q} = (1) x scalar(@q);
+ @poor_next_types{@q} = (1) x scalar(@q);
$poor_types{'L'} = 1;
$poor_next_types{'R'} = 1;
- @q = qw(eq ne le ge lt gt);
- @{poor_keywords}{@q} = (1) x scalar(@q);
- @{poor_next_keywords}{@q} = (1) x scalar(@q);
+ @q = qw(eq ne le ge lt gt);
+ @poor_keywords{@q} = (1) x scalar(@q);
+ @poor_next_keywords{@q} = (1) x scalar(@q);
} ## end BEGIN
sub examine_old_breakpoint {
# leading keywords which to skip for efficiency when making parenless
# container names
my @q = qw( my local our return );
- @{is_my_local_our}{@q} = (1) x scalar(@q);
+ @is_my_local_our{@q} = (1) x scalar(@q);
# leading keywords where we should just join one token to form
# parenless name
@q = qw( use );
- @{is_use_like}{@q} = (1) x scalar(@q);
+ @is_use_like{@q} = (1) x scalar(@q);
# leading token types which may be used to make a container name
@q = qw( k w U );
- @{is_kwU}{@q} = (1) x scalar(@q);
+ @is_kwU{@q} = (1) x scalar(@q);
# token types which prevent using leading word as a container name
@q = qw(
**= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.= <<~
);
push @q, ',';
- @{is_binary_type}{@q} = (1) x scalar(@q);
+ @is_binary_type{@q} = (1) x scalar(@q);
# token keywords which prevent using leading word as a container name
@q = qw(and or err eq ne cmp);
} ## end package Perl::Tidy::Formatter
1;
-
# Note that 'grep-alias-list' has been preprocessed to be a trimmed,
# space-separated list
my @q = split /\s+/, $rOpts->{'grep-alias-list'};
- @{is_grep_alias}{@q} = (1) x scalar(@q);
+ @is_grep_alias{@q} = (1) x scalar(@q);
}
$rOpts_starting_indentation_level = $rOpts->{'starting-indentation-level'};
^= &&= ||= //= <=>
#;
push @qZ, ',';
- @{Z_test_hash}{@qZ} = (1) x scalar(@qZ);
+ @Z_test_hash{@qZ} = (1) x scalar(@qZ);
}
sub do_DOLLAR_SIGN {
BEGIN {
my @qZ = qw( -> Z );
- @{is_arrow_or_Z}{@qZ} = (1) x scalar(@qZ);
+ @is_arrow_or_Z{@qZ} = (1) x scalar(@qZ);
}
sub tokenize_this_line {
push @q, ',';
push @q, '('; # for completeness, not currently a token type
push @q, '->'; # was previously in UNKNOWN
- @{op_expected_table}{@q} = (TERM) x scalar(@q);
+ @op_expected_table{@q} = (TERM) x scalar(@q);
# Always UNKNOWN following these types;
# previously had '->' in this list for c030
@q = qw( w );
- @{op_expected_table}{@q} = (UNKNOWN) x scalar(@q);
+ @op_expected_table{@q} = (UNKNOWN) x scalar(@q);
# Always expecting OPERATOR ...
# 'n' and 'v' are currently excluded because they might be VERSION numbers
# Fix for c250: added 'i' because new type 'P' was added
@q = qw( -- C h R ++ ] Q <> i ); ## n v q );
push @q, ')';
- @{op_expected_table}{@q} = (OPERATOR) x scalar(@q);
+ @op_expected_table{@q} = (OPERATOR) x scalar(@q);
# Fix for git #62: added '*' and '%'
@q = qw( < ? * % );
- @{is_weird_parsing_rule_exception}{@q} = (1) x scalar(@q);
+ @is_weird_parsing_rule_exception{@q} = (1) x scalar(@q);
@q = qw<) $>;
- @{is_paren_dollar}{@q} = (1) x scalar(@q);
+ @is_paren_dollar{@q} = (1) x scalar(@q);
@q = qw( n v );
- @{is_n_v}{@q} = (1) x scalar(@q);
+ @is_n_v{@q} = (1) x scalar(@q);
} ## end BEGIN
BEGIN {
my @q = qw< $ & % * @ ) >;
- @{is_sigil_or_paren}{@q} = (1) x scalar(@q);
+ @is_sigil_or_paren{@q} = (1) x scalar(@q);
@q = qw(R ]);
- @{is_R_closing_sb}{@q} = (1) x scalar(@q);
+ @is_R_closing_sb{@q} = (1) x scalar(@q);
} ## end BEGIN
sub is_non_structural_brace {
# Constants like 'pi' in Trig.pm are common
my @q = qw(pi pi2 pi4 pip2 pip4);
- @{is_known_constant}{@q} = (1) x scalar(@q);
+ @is_known_constant{@q} = (1) x scalar(@q);
# parenless calls of 'ok' are common
@q = qw( ok );
- @{is_known_function}{@q} = (1) x scalar(@q);
+ @is_known_function{@q} = (1) x scalar(@q);
} ## end BEGIN
sub guess_if_pattern_or_division {
# variables, like $^W: (issue c066).
my @q =
qw{ ? A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ };
- @{is_special_variable_char}{@q} = (1) x scalar(@q);
+ @is_special_variable_char{@q} = (1) x scalar(@q);
} ## end BEGIN
# These are the possible states for this scanner:
# lexical subs with these names can cause parsing errors in this version
my @q = qw( m q qq qr qw qx s tr y );
- @{warn_if_lexical}{@q} = (1) x scalar(@q);
+ @warn_if_lexical{@q} = (1) x scalar(@q);
} ## end BEGIN
# saved package and subnames in case prototype is on separate line
# /(\)|\}|\;|\&\&|\|\||and|or|while|if|unless)/
my @q = qw( & && | || ? : + - * and or while if unless);
push @q, ')', '}', ']', '>', ',', ';';
- @{pattern_test}{@q} = (1) x scalar(@q);
+ @pattern_test{@q} = (1) x scalar(@q);
} ## end BEGIN
sub pattern_expected {