in reply to Re^4: Is this a bug, or expected behavior?
in thread Is this a bug, or expected behavior?
It does because it is a scalar context.
Your problem is that you're not accepting/catching/groking that the parts inside the [] have their own context due to their nature (dereferencing a single element from an array reference) that's independent from the context of the larger expression. It doesn't matter how many of them you stack up, each of them is trying to retrieve a single element. Slices use @{ $aref }[ LIST ], single elements use ${ $aref }[ EXPR ]. The later is not the former, the former is not the later. They're two different things which impose different contexts on the subscripts.
Update: let me rewrite your example using the more explicit brace-y syntax I used; that might help clear it up. Your:
$a->[1..4]->[11..12]
is the same as:
${ ${ $a }[ 1..4 ] }[ 11..12 ]
A similar slice (which due to the indices you used wouldn't make much sense :) would be:
@{ @{ $a }[ 1..4 ] }[ 11..12 ]
But again, you don't have a slice, you're fetching a single element so it's scalar context inside the []s.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Is this a bug, or expected behavior?
by fizbin (Chaplain) on Mar 17, 2006 at 17:20 UTC |