Provided by: libperl-critic-community-perl_1.0.3-1_all
NAME
Perl::Critic::Policy::Community::LexicalForeachIterator - Don't use undeclared foreach loop iterators
DESCRIPTION
It's possible to use a variable that's already been declared as the iterator for a foreach loop, but this will localize the variable to the loop and its value will be reverted after the loop is done. Always declare the loop iterator in the lexical scope of the loop with "my". foreach $foo (...) {...} # not ok for $bar (...) {...} # not ok foreach my $foo (...) {...} # ok for my $bar (...) {...} # ok This policy is a subclass of the Perl::Critic core policy Perl::Critic::Policy::Variables::RequireLexicalLoopIterators, and performs the same function but in the "community" theme.
AFFILIATION
This policy is part of Perl::Critic::Community.
CONFIGURATION
This policy is not configurable except for the standard options.
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.
SEE ALSO
Perl::Critic perl v5.34.0 Perl::Critic::Policy::Community::LexicalForeachIterator(3pm)