|
|
| more useful options | |
| PerlMonks |
Re: Matching against list of patternsby tachyon (Chancellor) |
| on Sep 16, 2004 at 12:25 UTC ( #391421=note: print w/ replies, xml ) | Need Help?? |
|
The typical method is to dynamically build an alternation RE and let the RE engine do all the optimisation and hard work in lovingly hand optimised C. We use qr// so the RE is compiled once and avoid vast numbers of hash lookups, functionally useless variable assignments*, and RE compiles that you are doing above. As a general rule loops are great territory for optimisation due to the repeated execution of the loop code.
Hash lookup tables may still have a place to convert a matched value into something else. Here is a trivial example. Beware /i as you need to lc($1) and use all lowercase keys in %terms or you won't get a match/lookup.
cheers tachyon
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||