David Christensen wrote:
beginners@perl.org:
Hello,
I'm working on some classes with attributes that are array and hash references, and am confused by what happens when I attempt to slice an array or hash reference. For example: 7. "$ra->[0, 1, 2]" evaluates to $ra->[2].
$ra is a scalar that holds a reference to an array. $ra->[0] dereferences an array element. To dereference an array slice use:
@{ $ra }[ 0, 1, 2 ]
8. "$ra->[0 .. 2]" produces two "Use of uninitialized value in range (or flip)" warnings and evaluates to $ra->[1].
Same here: @{ $ra }[ 0 .. 2 ] John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/