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


in reply to Need help comparing against a set of regexps

You can cut out the loop by doing something like:

my @regexes = ('hello(\w+)','foo(\d+)','zubbble(.*)'); my $re = join '|', sort { length $b <=> length $a } @regexes; $re = "(?:$re)"; print "Matched!\n" if 'foo123' =~ /$re/;
Check out the perlre manpage for more on how this works.

/J\