BUU, what you want is Regexp::Assemble, and create a pattern in "tracked" mode. This will allow you to assemble a single pattern against which to test strings. Big efficiency gain there.
You can then recover the original pattern that triggered the match, use that as a key into a dispatch table, passing in the captured fields. Have a look at eg/ircwatcher to get some ideas. A more advanced version appeared in Perl Hacks, if you happen to have a copy lying around.
• another intruder with the mooring in the heart of the Perl
In reply to Re: Optimizing many many regex matches
by grinder
in thread Optimizing many many regex matches
by BUU
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |