Q:

How to find index of string in array Perl without iterating

I need to find value in array without iterating through whole array.
I get array of strings from file, and I need to get index of some value in this array, I have tried this code, but it doesn't work.  
my @array =<$file>;
my $search = "SomeValue";
my $index = first { $array[$_] eq $search } 0 .. $#array;

print "index of $search = $index\n";

Please suggest how can I get index of value, or it is better to get all indexes of line if there are more than one entry.
Thx in advance.

A:

What does "it doesn't work" mean?
The code you have will work fine, except that an element in the array is going to be "SomeValue\n", not "SomeValue".  You can remove the newlines with chomp(@array) or include a newline in your $search string.

