Perl::Critic::Policy::Community::DollarAB - Don't use $a or $b as variable names outside sort
The special variables $a and $b are reserved for sort() and similar functions which assign to them to iterate over pairs of values. These are global variables, and declaring them as lexical variables with my to use them outside this context can break usage of these functions. Use different names for your variables.
$a
$b
sort()
my
my $a = 1; # not ok my $abc = 1; # ok sort { $a <=> $b } (3,2,1); # ok
This policy is part of Perl::Critic::Community.
This policy can be configured to allow $a and $b in additional functions, by putting an entry in a .perlcriticrc file like this:
.perlcriticrc
[Community::DollarAB] extra_pair_functions = pairfoo pairbar
Dan Book, dbook@cpan.org
dbook@cpan.org
Copyright 2015, Dan Book.
This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0.
Perl::Critic
To install Perl::Critic::Community, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Community
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Community
For more information on module installation, please visit the detailed CPAN module installation guide.