in reply to Re: Determing the indice of an array
in thread Determing the indice of an array

A little heavy. For one thing, it seems safe to assume that they are searching an array, not a constant list. Thus, you don't really need the trinary operator:

my @ary = (...); my $index; for $index (0 .. $#ary) { last if $ary[$index] eq $val; } print "Index = $index\n";

(Handling the case of no match is left as an exercise to the reader. Because I'm lazy today.)

As others have pointed out, conversion to a hash has a lot of drawbacks, not the least of which being the duplicate-value problem and the fact that it just isn't as efficient as travelling the array like above. Converting to a hash is still going to walk the array.

--rjray