in reply to Need help comparing against a set of regexps
You can cut out the loop by doing something like:
Check out the perlre manpage for more on how this works.my @regexes = ('hello(\w+)','foo(\d+)','zubbble(.*)'); my $re = join '|', sort { length $b <=> length $a } @regexes; $re = "(?:$re)"; print "Matched!\n" if 'foo123' =~ /$re/;
/J\
|
---|
In Section
Seekers of Perl Wisdom