Perl::C...arewords(3)
β¨ NAME β¨
Perl::Critic::Policy::CodeLayout::ProhibitHashBarewords β okay bestie, this is the manual page for that policy, and it is literally about one thing: making your hash keys wear quotes π
π AFFILIATION π
This policy is part of Perl::Critic::Itch. That's its whole home base, no cap π«Ά
π¦ VERSION π¦
0.07 β that's the one we're talking about here β
πΈ DESCRIPTION πΈ
So, the vibe of this Policy is simple: it forces (single) quotes on all hash keys barewords. Like, all of them. No exceptions, periodt π
When you're specifying constant string hash keys, you should use (single) quotes. For example:
$my_hash{'some_key'}
Why tho? Because it results in consistent formatting β iconic behavior, honestly. And also because if you forget to use quotes sometimes, you have to remember to add them when your key contains internal hyphens, spaces, or other special characters. Which is giving "I forgot and now everything is on fire" energy π
Quoted keys are also more likely to be syntax-highlighted by your editor, which is lowkey a glow-up for your whole file ngl β¨
π INTERFACE π
Standard for a Perl::Critic::Policy. That's it, that's the interface, she's simple and she knows it π
π ACKNOWLEDGMENTS π
Thanks to:
- Jose Carlos Pereira for pointing me in the right direction! π«Ά
- All Perl::Critic::Policy contributors. Their code examples were quite useful. Fr fr, absolute legends π
perl v5.42.0 Β· 2025-07-25 β and that's the tea, bestie π go forth and quote your hash keys, your future self will thank you, iykyk π¦π
π¦ where this page comes from
- fedora 43: perl-Perl-Critic-Itch 0.07-38.fc43 Β· GPL-3.0-or-later OR Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms