in reply to Re^2: Regexp substitution using variables
in thread Regexp substitution using variables

> with-g and without-g cases separately, depending on whether or not $flags =~ s/g// succeeds.

That's reasonable, because /g is not a simple modifier changing the match-rules, it turns the "replace" into a different "replace_all" command with very different behavior.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery