![]() |
|
There's more than one way to do things | |
PerlMonks |
Re: Re: Re: using a hash to do substitution?by tachyon (Chancellor) |
on Jun 14, 2001 at 11:02 UTC ( #88313=note: print w/replies, xml ) | Need Help?? |
Rather than speculate on efficiency you can always use benchmark. One small point though - whenever you interpolate a string into a m// regex or the first half of a s/// regex you need to backslash your special regex metacharacters $^*()+{[\|.? The easiest way is to use quotemeta.
This is *vital* for reliability. Otherwise you will get unexpected runtime failures when your data eventually contains metachars (typos, deliberate, malicious...)
So as it happens alternation is twice as fast. I thought your solution would be faster but there you go! If in doubt - use Benchmark Cheers tachyon
In Section
Seekers of Perl Wisdom
|
|