for my $i ( 0 .. $#AoA ) { for my $j ( 0 .. $#{$AoA[$i]} ) { if ($AoA[$i][1]==$max) { print $AoA[$i][0]."\n"; } } }