in reply to Re: regex "o" modifier
in thread regex "o" modifier
When Perl encounters a variable in a regex it can't be sure that the variable will never change and so it compiles it each time the regex is used.That used to be true, long time ago, but it is no longer so. Even if your regexp contains variables and you don't use /o, perl may still not compile it again... simply because these days, perl contains a check to see if the scalar has changed since last time the regexp got compiled...
Benchmarking will show you that, in case the scalar doesn't change, not using /o is comparable in speed, or might even be appear slightly faster (difference < 1%) than when using /o — but likely that's just inaccuracies in the benchmark.
/o does prevent recompiling the regexp, even if the scalar changes. Likely this is not what you want.
Therefore, use of /o in modern perl is largely obsolete.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: regex "o" modifier
by diotalevi (Canon) on May 15, 2003 at 00:16 UTC |
In Section
Seekers of Perl Wisdom