On Mittwoch, 20. August 2008, Per Jessen wrote:
Can anyone epxlain to me what the 'o' modifier achieves (or not) in this example:
$copy =~ s/[[:graph:]]+//go;
perldoc perlre doesn't explain it, but perldoc perltut does:
" % cat > simple_replace
#!/usr/bin/perl
$regexp = shift;
$replacement = shift;
while (<>) {
s/$regexp/$replacement/go;
print;
}
^D
% simple_replace regexp regex perlretut.pod
In "simple_replace" we used the "s///g" modifier to replace all occurrences of
the regexp on each line and the "s///o" modifier to compile the regexp only once.
"
So it seems to be just a performance optimization.
HTH
--
Stefan Hundhammer