grep $array
$_ eq $search_for, 0 .. $#array;
will return matched array which stores the index of the matching words.
my @index_arr = grep {$array
$_ eq $search_for} 0 .. $#array;
or
my @index_arr = grep $array
$_ eq $search_for, 0 .. $#array;
foreach (@index_arr) {
print "matching position = $_\n";
}