my @REs = qw( this that \w\d\w ); my $re = join '|', @REs; # join with | for alternation $re = qr/($re)/; # compile for efficiency print "Matched $1\n" if $str =~ m/$re/;