Per Jessen wrote:
Anders Johansson wrote:
On Wednesday 20 August 2008 14:40:50 Per Jessen wrote:
Can anyone epxlain to me what the 'o' modifier achieves (or not) in this example:
$copy =~ s/[[:graph:]]+//go; It means that the regexp engine will precompile the regular expression, and not recompile it every time the line is executed. Described in "man perlop"
So purely a minor performance optimization?
In that example I don't think it does anything. The normal use is when there is a variable substitution: while () { /abc$variable.../ } The regex is recompiled on every iteration. /o just compiles it once and that makes a measurable difference if the loop is executed enough times or if the variable is something more complicated. If the variable changes during the iterations, /o also changes the semantics, of course, so it's not always just an optimization. Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org