in reply to Re: Regex Tuning
in thread Regex Tuning /(?:(?:foo[34])|(?:bar[12]))\.txt/io

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Regex Tuning
by dragonchild (Archbishop) on Apr 28, 2005 at 15:31 UTC
    /o isn't all that useful in the general case. First off, it's only useful if you have variables in your regex definition, which isn't the case here. Secondly, it is often counter-intuitive because it locks the regex into the variable as it was when you defined the regex.

    The Perfect is the Enemy of the Good.

Re^3: Regex Tuning
by salva (Canon) on Apr 28, 2005 at 15:38 UTC
    no, /.../o is very rarely useful, only when you are including some var $foo inside the regexp and $foo it's not going to change after the first match.

    Recent perl versions include the qr// operator that allows to precompile regexp. It is what you should use when you have speed problems with dynamically generated regexps.

Re^3: Regex Tuning
by deibyz (Hermit) on Apr 28, 2005 at 15:33 UTC
    /o can only help to improve the speed if the pattern has any variable, wich isn't the case. So /o is not needed. Also, it's almost every time a better choice to use qr//
A reply falls below the community's threshold of quality. You may see it by logging in.