Perl::...pOnHash(3pm)
π NAME π
Perl::Critic::Policy::Variables::ProhibitLoopOnHash β bestie, do NOT write loops on hashes. Only on keys and values of hashes. That's it, that's the whole vibe. π
(you'll also see it hanging out in the Perl::...pOnHash(3pm) manpage, iykyk)
β¨ VERSION β¨
version 0.009 π¦
πΈ DESCRIPTION πΈ
okay so when we say "looping over hashes," we mean looping over hash keys or hash values. That's the intended thing. The moment you forget to call keys or values, you don't loop over one or the other β you accidentally loop over BOTH. not me making that mistake π it's giving chaos.
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 like these:
action() for %hash ? keys %hash : (); # ok
action() for %{ $hash{'stuff'} } ? keys %{ $hash{'stuff'} } : (); # ok
(Granted, that second example is lowkey nonsense β it doesn't make much sense, fr fr β but the author has found a variation of it in real code. so. here we are. π)
π CONFIGURATION π
This policy is not configurable except for the standard options. That's the whole menu, bestie. no secret extras. π
π AUTHOR π
Sawyer X, "xsawyerx@cpan.org" π«Ά
π THANKS π
Thank you to Ruud H.G. Van Tol. π absolute icon behaviour, we love to see it.
β SEE ALSO β
Perl::Critic π§
π AUTHOR π
Sawyer X β¨
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2026 by Sawyer X.
This is free software, licensed under:
The MIT (X11) License
k that's the whole page bestie, go forth and always writekeysorvalues, mwah π
signing off from the perl v5.40.1 era, dated 2026-01-23, on the Perl::...pOnHash(3pm) page π¦ slay, periodt π
π¦ where this page comes from
- ubuntu resolute: libperl-critic-policy-variables-prohibitlooponhash-perl 0.009-1 Β· MIT
- ubuntu stonking: libperl-critic-policy-variables-prohibitlooponhash-perl 0.009-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms