Perl-Lint

 view release on metacpan or  search on metacpan

t/Policy/Variables/require_localized_punctuation_vars.PL  view on Meta::CPAN

END_CODE

    for my $varname (@{$globals}) {
        next if $exemptions{$varname};
        print {$test_file} "($varname) = ();\n";
    }

    return;
}


sub print_fail_non_local_deref {
    my ($test_file, $globals) = @_;

    my %subscript = (
        '%' => '{foo}',
        '@' => '[0]',
    );

    my @derefs = grep { $subscript{substr $_, 0, 1} && !$exemptions{$_} }
        @{ $globals };
    my $numvars = scalar @derefs;

    print {$test_file} <<"END_CODE";

===
--- dscr: Named magic variables, fail non-local dereferenced
--- failures: $numvars
--- params:
--- input
END_CODE

    foreach my $varname ( @derefs ) {
        my ($sigil, $barename) = $varname =~ m/ (.)(.*) /smx;
        print {$test_file} '$', $barename,
            $subscript{$sigil}, " = 'bar';\n";
    }

}


sub print_footer {
    my ($test_file) = @_;

    print {$test_file} <<'END_CODE';

===
--- dscr: Allowing a variable with a particular sigil doesn't allow other variables with the same name but different sigils
--- failures: 1
--- params: {require_localized_punctuation_vars => {allow => '$ARGV'}}
--- input
@ARGV = (1, 2, 3);

===
--- dscr: Allow "my" as well, RT #33937
--- failures: 0
--- params:
--- input
for my $entry (
   sort {
       my @a = split m{,}xms, $a;
       my @b = split m{,}xms, $b;
       $a[0] cmp $b[0] || $a[1] <=> $b[1]
   } qw( b,6 c,3 )
   )
{
   print;
}

END_CODE

    return;
}



( run in 0.874 second using v1.01-cache-2.11-cpan-71847e10f99 )