in reply to Re: sorting array of array references with multiple dereferenced array elements
in thread sorting array of array references with multiple dereferenced array elements
> for my $i (0 .. $#a) {
looks wrong: $a is an array ref there is no @a involved.
IIRC $#$a should do.
Note This code is untested. ;)
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
now tested! :)
DB<109> $a=[1..10] # arrref => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] DB<110> $#$a => 9 DB<111> $a=[map [0..$_],0..3 ] # AoA => [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3]] DB<112> $#{$a->[2]} => 2 DB<113> @b=(1..5) # @array => (1, 2, 3, 4, 5) DB<114> $#b => 4
though I couldn't find a good documentation yet! :(
|
|---|