my $min_diff_past = max (@all_date_diffs_past); for my $j ( 0 .. $#AoA_past ) { if ($AoA_past[$j][1]==$min_diff_past) { print $AoA_past[$j][0]."\t"; } }