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 ];
...
> @slice = @$ra[ 1 .. 3 ];

Yup:

    http://www.perlmonks.org/?node_id=80399

ok 7 - @{$ra}[0, 1, 2]       a b c
ok 8 - @{$ra}[0 .. 2]        a b c

ok 30 - @{fra()}[0, 1, 2]     a b c
ok 31 - @{fra()}[0 .. 2]      a b c

ok 42 - @{$oa->ra}[0, 1, 2]   a b c
ok 43 - @{$oa->ra}[0 .. 2]    a b c


The other issue was "Ambiguous use of @{fra} resolved to @fra" (tests 28 and 35). The solution is to put "+" in front of the function name:

ok 28 - @{+fra}               a b c d e f
ok 35 - @{+fra}[0, 1, 2]      a b c


Thanks!

David

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to