Perl::Critic::Policy::Community::LexicalForeachIterator - Don't use undeclared foreach loop iterators
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.
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.
community
This policy is part of Perl::Critic::Community.
This policy is not configurable except for the standard options.
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.