|Perl: the Markov chain saw
Re: meaning of /o in regexesby BrowserUk (Patriarch)
|on Dec 06, 2002 at 12:48 UTC
My understanding, which is confirmed by your tests, is that when you use the /o modifier, any variables within the regex will only be interpolated the first time the regex is seen.
This appears to be similar in effect to using the qr// op to create your regexes in advance. However, using qr// has the advantage that you can pre-compile your regexes in sections and then combine them in the m// and s/// operators in different combinations.
A few things I haven't seen an explanation for (they may exist, I just haven't seen them):
I did once attempt to systematically benchmark these to try and determine what coptions and combinations of options had greatest benefit from the performance standpoint, but the process is fraught with gotchas.
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.