Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Complicated Hash Construction.

by Trimbach (Curate)
on Dec 29, 2002 at 04:26 UTC ( [id://222847]=note: print w/replies, xml ) Need Help??


in reply to Complicated Hash Construction.

I always thought it was because in the first example perl knows that %hash is, well, a hash. In the second example perl has no way of knowing whether @hash is a hash or an array. It looks like an array (and the right-hand side is in list context) and the braces look like a syntax error.

There's no problem when you predeclare %hash because perl knows that @hash{ } is a hash slice and not an array.

Those more knowledgable about the Perl internals can comment on why this syntax can't be DWIM'd into the interpreter, but I suspect it will not be an issue in Perl 6.

Gary Blackburn
Trained Killer

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found