>perl -wMstrict -le "use List::MoreUtils qw(indexes); ;; my @ra = ( 'DATA', 'LIST', 'DATALIST', 'FOO', ' DATALIST ', 'data list', 'DATA LIST', ' DATA LIST ' ); ;; my $search = qr{ DATA \s+ LIST }xms; ;; my @indices = indexes { $_ =~ $search } @ra; print qq{at index $_ found '$ra[$_]'} for @indices; " at index 6 found 'DATA LIST' at index 7 found ' DATA LIST '