- or download this
my %lookup = map { $_ => undef } @array;
print "There it is\n" if exists $lookup{foo};
- or download this
my %lookup = map { $array[$_] => $_ } 0 .. $#array;
my $index = $lookup{foo};
- or download this
my @indices = grep { $array[$_] eq 'foo' } 0 .. $#array;