Modifiers
The /o Modifier
There are some instances, where a variable will contain the same value each time it is used in an expression. This is when we would use the /o modifier. The /o modifier tells the RegEx Engine to resolve any variables only once, and to remember the REPLACEMENT string for this substitution.
my $string = "abc"; foreach my $value (@values) { $value =~ s/^/$string/o; }
|
If we didn't use the /o modifier, each REPLACEMENT string would have to be resolved to "abc" before the regular expression could be created. |