http://qs321.pair.com?node_id=150685


in reply to (ar0n) Re: Need help comparing against a set of regexps
in thread Need help comparing against a set of regexps

Is there a way to do this in Perl5? I don't have the qr// thing.
  • Comment on Re: (ar0n) Re: Need help comparing against a set of regexps

Replies are listed 'Best First'.
(ar0n) Re (3): Need help comparing against a set of regexps
by ar0n (Priest) on Mar 10, 2002 at 07:40 UTC

    qr was added in Perl 5.005_03. If you're running anything older than that, you should consider an upgrade, as previous versions are considered buggy.


    my @regexes = ('HELLO(\w+)', 'hello(\w+)', 'Hello(\w+)'); for my $re (@regexes) { $re =~ s!/!\/!; # escape delimiters my $eval = '$string =~ /' . $re . '/;'; if ( eval $eval ) { print "$string matches $re\n"; } }
    It's an ugly hack, and I would very much prefer it if you would promote world peace, fight hunger and help stop global warming by upgrading your version of Perl.

    [ ar0n -- want job (boston) ]