Perl::Critic::Policy::Community::LexicalForeachIterator3pm
Don't use undeclared foreach loop iterators
Overview
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 okfor $bar (...) {...} # not okforeach my $foo (...) {...} # okfor 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.
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.
Releases
2 releases since Debian 12 (Bookworm); the text changed 1 time.