in reply to Matching an array of regexes (grep in reverse)

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

Replies are listed 'Best First'.
Re^2: Matching an array of regexes (grep in reverse)
by bingos (Vicar) on Nov 21, 2008 at 12:33 UTC

    Or Regexp::Assemble

    use Regexp::Assemble; my $re = Regexp::Assemble->new(); $re->add($_) for @regex; if ( $str =~ /$re/ ) { ... }