in reply to Re^2: Finding index of an entry in an Array
in thread Finding index of an entry in an Array
Not without parens (since grep in scalar context returns the number of matching elements) and not without searching the entire list of indexen (which of course could be what the OP really wants, the indexen of all matching elements).
my( $idx ) = grep { $array[ $_ ] eq 'bar' ) 0..$#array; my @indexen = grep { $array[ $_ ] eq 'bar' } 0..$#array;
That aside, yup that's another way to do it. :)
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|