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.
In reply to Re: Finding index of an entry in an Array
by Fletch
in thread Finding index of an entry in an Array
by monkfan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |