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):
Eg.
my $re_int = qr/[+-]?\d+/; my $re_exp = qr/[Ee][+-]?$re_int/; if ($str =~ m/^(?:$re_int\.)?$re_int$re_exp?$/ ) { print "I think I got a valid int or float"\n"; }
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.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.
In reply to Re: meaning of /o in regexes
by BrowserUk
in thread meaning of /o in regexes
by mce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |