The following snippet searches for the index of the first occurrence of a value in an array. However, when the parentheses around $index are removed, it does not function correctly. What am I doing wrong?
my ($index) = grep { $array[$_] eq $search_for } 0..$#array;