Syntactic Confectionery Delight | |
PerlMonks |
Re^3: Is this a bug, or expected behavior?by xdg (Monsignor) |
on Mar 17, 2006 at 15:51 UTC ( [id://537481]=note: print w/replies, xml ) | Need Help?? |
The [1..4] in list context is used with slices -- it doesn't create a list context on its own. Because you ask for $a->, you're telling Perl to dereference $a to a single element, not a slice, thus 1..4 is interpreted in scalar context. In the case that works, you're dereferencing $a to an array, and then taking a slice of that -- and because you're slicing, 1..4 gets interpreted in list context.
-xdg Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In Section
Seekers of Perl Wisdom
|
|