NAME
Perl::Critic::Policy::Freenode::DollarAB - Don't use $a or $b as variable names outside sort
DESCRIPTION
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.
my $a = 1; # not ok
my $abc = 1; # ok
sort { $a <=> $b } (3,2,1); # ok
AFFILIATION
This policy is part of Perl::Critic::Freenode.
CONFIGURATION
This policy can be configured to allow $a
and $b
in additional functions, by putting an entry in a .perlcriticrc
file like this:
[Freenode::DollarAB]
extra_pair_functions = pairfoo pairbar
AUTHOR
Dan Book, dbook@cpan.org
COPYRIGHT AND LICENSE
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.