in reply to Grep reutrn the occurance of a pattern

See How (Not) To Ask A Question, but (completely off the wall guess here) perhaps you want to grep over the indexen rather than the array itself?

my @array = qw( foo bar baz quux ); my @idx_of_eles_with_an_a = grep $array[ $_ ] =~ /a/, 0..$#array;

The cake is a lie.
The cake is a lie.
The cake is a lie.