Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Complicated Hash Construction.

by Trimbach (Curate)
on Dec 29, 2002 at 04:26 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2016-10-27 06:17 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (353 votes). Check out past polls.