my $common_re = join '|', @regex; if ($str =~ m/$common_re/) { ... }