[Kc] infix pointer question

David Nicol davidnicol at gmail.com
Thu Aug 31 14:59:51 PDT 2006


On 8/31/06, Andrew Moore <amoore at mooresystems.com> 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
#


More information about the kc mailing list