perl-Perl-Critic-Policy-Variables-ProhibitLoopOnHash
Don't write loops on hashes, only on keys and values of hashes
When "looping over hashes," we mean looping over hash keys or hash values. If you forgot to call 'keys' or 'values' you will accidentally loop over both. foreach my $foo (%hash) {...} # not ok action() for %hash; # not ok foreach my $foo ( keys %hash ) {...} # ok action() for values %hash; # ok An effort is made to detect expressions: action() for %hash ? keys %hash : (); # ok action() for %{ $hash{'stuff'} } ? keys %{ $hash{'stuff'} } : (); # ok (Granted, the second example there doesn't make much sense, but I have found a variation of it in real code.)
Artistic-1.0 OR GPL-1.0-or-later