my ($result2) = map { $array[$_][0] =~ /goat/ ? $_ : () } 0..$#array; my ($result3) = grep { $array[$_][0] =~ /goat/ } 0..$#array;