in reply to Optional quotes: to use or not to
Our $work style guide says to use no quotes and no spaces for such hash keys because it is easier to search for {word} than for any of {word}, { word }, {"word"}, {'word'}, and some more obscure styles of quoting. Similarly, you can search for /\bword\s*=>/ more easily than trying to guess what type of quoting might be used; and adding quotes means somebody might not have even used =>.
On rare occasions, you have a mix of bareword keys and keys with hyphens or dots and have to mix: word => $word, 'non-word' => $non_word. But I have not found that to be a disadvantage.
Of course, the advantage is fairly minor in the scheme of things.
Then there is the idea of avoiding retyping such key names where a typo won't be caught for you and so you define constants for your keys and end up with $WORD => $word or WORD() => $word. Or just avoid using a hash and use separate variables (especially for command-line options).
- tye
|
|---|