my @a2=map { $array[$_][0] } 0..$#array; my ($goat_idx) = grep{ $a2[$_] eq "goat" } 0..$#a2; print "Goat index is $goat_idx.\n";