use strict; use warnings; use Data::Dump qw/pp dd/; use List::Util qw(min max); use constant { name=>0, num=>1 }; my @AoA = ( ["nick","99"], ["john","88"], ["peter","77"], ["thomas","99"] ); my $max_num = max map { $_->[num] } @AoA; my @max_names = map { $_->[name] } grep { $_->[num] == $max_num } @AoA; pp @max_names;
and for completeness another variant
my @max_names = map { $_->[num] == $max_num ? $_->[name] : () } @AoA;
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re^3: help with an array of arrays
by LanX
in thread help with an array of arrays
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |