in reply to Finding index of an entry in an Array
Aside from the fact that the index of 'bar' in your sample array is 1 not 2 (remember array indexen start at 0) . . .
use List::Util qw( first ); my $idx = first { $repo[ $_ ] eq 'bar' } 0..$#repo;
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Finding index of an entry in an Array
by snoopy (Curate) on Dec 07, 2007 at 03:48 UTC | |
|
Re^2: Finding index of an entry in an Array
by tuxz0r (Pilgrim) on Dec 07, 2007 at 03:36 UTC | |
by Fletch (Bishop) on Dec 07, 2007 at 03:45 UTC |