in reply to Hash initialization works, but why?
It's rather like the whole beginner array-vs-array-item confusion that so many people encounter, at least briefly: if @x is my array, surely item 3 in @x should be @x[3] ?
But of course it's not, it's $x[3] because the item itself is a scalar.
In this case, even though we're retrieving from (or in your case assigning to) a hash, we're interacting with it in a list-centric way rather than a one-thing-at-a-time way.
So @x{...} refers to %x. It has nothing to do with @x at al, and also nothing to do with typeglobs.
The trick is to understand that the kind of brackets around the index ({} vs []) determine whether it's an array or hash that you're dealing with, not the symbol at the front, which only determines how many things you're dealing with in one operation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash initialization works, but why?
by ikegami (Patriarch) on Jun 04, 2008 at 23:09 UTC | |
by throop (Chaplain) on Jun 04, 2008 at 23:23 UTC | |
by chromatic (Archbishop) on Jun 05, 2008 at 00:56 UTC | |
by throop (Chaplain) on Jun 05, 2008 at 14:14 UTC | |
by ikegami (Patriarch) on Jun 04, 2008 at 23:31 UTC | |
by ikegami (Patriarch) on Jun 05, 2008 at 02:38 UTC |