my $re = 'fo+|zzz'; my @matches = grep /$re/, qw/ f fo foo bar foobar zzzz /; print "@matches"; #### fo foo foobar zzzz