On 8/31/06, Andrew Moore <[EMAIL PROTECTED]> wrote:
> (I believe that this
> is more formally written as "$obj->{ 'data' }->{ 'madein' };" but you
> can leave out that second arrow because it's kind of redundant)

you can also leave out the quotes around the key names because
barewords in curlies used as hash keys are interpreted as names,
even in the presence of similarly named functions:

# perl -wle 'sub f(){print "called f"}; $h{f} = 4; print keys %h'
f
# perl -wle 'sub f(){print "called f"}; $h{ f } = 4; print keys %h'
f
# perl -wle 'sub f(){print "called f"}; $h{ f() } = 4; print keys %h'
called f
1
# perl -wle 'sub f(){print "called f"}; $h{ $x=f } = 4; print keys %h'
Name "main::x" used only once: possible typo at -e line 1.
called f
1
# perl -wle 'sub f(){print "called f"}; $h{ $x="f" } = 4; print keys %h'
Name "main::x" used only once: possible typo at -e line 1.
f
#
_______________________________________________
kc mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/kc

Reply via email to