Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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


Comment on Re: Complicated Hash Construction.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2014-12-18 19:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (61 votes), past polls