Perl::Critic::Policy::CodeLayout::ProhibitHashBarewords
This policy is part of Perl::Critic::Itch.
0.03
This Policy required (single) quotes all hash keys barewords.
When specifying constant string hash keys, you should always use (single) quotes. E.g., $my_hash{'some_key'}
I believe that this is the appropriate choice because it results in consistent formatting and if you forget to use quotes sometimes, you have to remember to add them when your key contains internal hypens, spaces, or other special characters.
Quoted keys are also more likely to be syntax-highlighted by your editor.
When using a bareword as a hash key, we should always use backtips to mode the code more legible.
Things as $my_elem{some_bareword} should be writen as $my_elem{'some_bareword'}
Stadard for a Perl::Critic::Policy.
To install Perl::Critic::Itch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::Itch
CPAN shell
perl -MCPAN -e shell install Perl::Critic::Itch
For more information on module installation, please visit the detailed CPAN module installation guide.