What I do is treat hashkeys like radioactive waste: I handle them directly as little as possible. If I can programmatically generate them in one way or another, I do. If not, I limit my "direct contact" with them (i.e. cases where I actually type out a hash key) to a single initial typing of the key (usually as one in a list of arguments to qw). (Typing each key once is usually OK; it's when one has to type the same key more than once that troubles begin.)
For fields of hashref-based objects, I avoid accessing the hash slot directly, and define accessors instead. A mistyped hashkey won't trigger an error from Perl, but a mistyped accessor will.
If a program's design is such that multiple typing of the same key is unavoidable, I begin thinking about how to restructure the code.
the lowliest monk
In reply to Re: avoiding hash key typos
by tlm
in thread avoiding hash key typos
by shemp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |