in reply to Re: Regexp substitution using variables
in thread Regexp substitution using variables
Even string eval doesn't help, as plain interpolation of the $replacement can break if it contains a slash
My first thought was to use eval but I hit a brick wall when I tried...
I was thinking of first changing a slash in $replacement for a double slash then using eval to do the substitution but I got stuck getting the result of the substitution.
But that doesn't do it...$replacement =~ s/\\/\\\\/g; $string =~ eval "s/\$pattern/\$replacement/$flags";
|
|---|