Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Correct keys in hashes

by flogic (Acolyte)
on Aug 25, 2004 at 19:04 UTC ( [id://385778]=note: print w/replies, xml ) Need Help??


in reply to Correct keys in hashes

I used to always quote them. But that took forever so now I don't. However for the parnoid it's probably better. Lest some day you do something like...
my($count)=0; sub name() {'autoname'.$count++} $foo{name}='bob';
I'll still probably skip the quotes until the it day bites me since I don't type so quick.

Replies are listed 'Best First'.
Re^2: Correct keys in hashes
by Aristotle (Chancellor) on Aug 25, 2004 at 20:30 UTC

    That doesn't have anything to do with quoting keys. $foo{name} will always be interpreted as $foo{'name'}, and there's no way you can disambiguate that by using or not using quotes.

    If that was supposed to call your name function, you should have written it with parens, as in $foo{name()}. In fact, you should get in the habit of never calling functions without parens. (And of using sub strictures.) That will disambiguate almost every case of possible confusion that crops up in Perl.

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found