Sitha Nhok wrote:
> Hi, if I have a multidimensional array like :
>
> @AoA = (
> ["ABC", "BCD"],
> ["CDE", "DEF"],
> ["EFG", "FGH"],
> );
>
>
> then do:
>
> @var = splice @AoA, 2, 1; # to delete the last row
>
> print @var; #print what was returned from splice
>
>
>
> The print statement prints an address. I like it to print the contents
> that was removed. How do I do that?
Hi Sitha.
As Rob Anderson points out, @AoA is an array of array references, not
an inherently two-dimensional array. However it may be worh pointing
out that
@var = splice @AoA, 2, 1;
is, as you say, removing the last element of @AoA and returning it. This
is the same as
@var = pop @AoA
but this will give you a new array with one element that looks like
@var = (
["EFG", "FGH"],
);
What you may want is to dereference this before you assign it to the array
like this
my @var = @{pop @AoA};
which leaves
@var = ( "EFG", "FGH" );
so you can say
print "@var\n";
getting
EFG FGH
as output.
I hope this helps.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]