Re: slicing array references

2011-12-19 Thread Uri Guttman
On 12/18/2011 08:53 PM, David Christensen wrote: beginners@perl.org: 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]. 8. "$

Re: slicing array references

2011-12-18 Thread David Christensen
On 12/18/2011 06:05 PM, John W. Krahn wrote: $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 ] ... @{ $ra }[ 0 .. 2 ] On 12/18/2011 06:14 PM, Shawn H Corey wrote: > my @slice = @$ra[ 1, 2, 3 ]; ..

Re: slicing array references

2011-12-18 Thread Shawn H Corey
On 11-12-18 09:05 PM, John W. Krahn wrote: 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]"

Re: slicing array references

2011-12-18 Thread John W. Krahn
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 th

slicing array references

2011-12-18 Thread David Christensen
beginners@perl.org: 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]. 8. "$ra->[0 .. 2]" produces two "Use of uninitial