in reply to How to find the index of an element in an array?

List::MoreUtils is implemented in C and might give a modest performance advantage.
#!/usr/bin/perl -w use List::MoreUtils; my @foo=('a','b','c', 'd', 'e', 'f', 'g', 'h', 'i'); my $index = List::MoreUtils::first_index {$_ eq 'g'} @foo; print ("G's index = $index\n");

Replies are listed 'Best First'.
Re^2: How to find the index of an element in an array?
by bsb (Priest) on Sep 07, 2005 at 01:58 UTC
    There is also "indexes" if there may be more than one "g"