map and
grep are high order function able to make one line of Perl very, very expressive. The positive part of your question lead me to address you to practice theese function. Also the book High Order Perl can be interesting for you, if you can afford it, given your actual Perl skill (mine is stil to low to end the book..)
That said, probably
compiler is happier with plain code
Nothing new after
Anonym's answer but 'say list of indexes that match xxx' is:
perl -E "say grep {$ARGV[$_]=~/xxx/} 0..$#ARGV" aaa xxx bb cc xxx dd x
+xx eee
146
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.