Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Should I use Fields, InsideOuts, or Properties?

by dmitri (Priest)
on Jul 06, 2005 at 14:55 UTC ( #472837=note: print w/replies, xml ) Need Help??

in reply to Should I use Fields, InsideOuts, or Properties?

Instead of


do this:

use constant TYPO => 'typo'; $hashref->{(TYPO)}; # OK $hashref->{(TIPO)}; # Compile-time error, just what you want

Replies are listed 'Best First'.
Re^2: Should I use Fields, InsideOuts, or Properties?
by djp (Hermit) on Jul 08, 2005 at 04:00 UTC
    That's (a) disgusting, and (b) largely useless, since it won't catch $hashref->{tipo};.
      The whole point is not to use quoted or literal strings for hash keys, but make yourself use constants and force compile-time check by placing parentheses around them.

      One added benefit of such approach is that if you want to change the actual key value, you only have to change it in one place.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://472837]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2019-12-11 06:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found