in reply to Re: Exec'ing a regex stored in a scalar variable
in thread Exec'ing a regex stored in a scalar variable

Depends on your amitiousness.

$regexp = qr/a(b+)c/; $subst = 'c$1a'; my @a = $string =~ $regexp; $subst =~ s/\$(\d)/$a[$1-1]/ge; $string =~ s/$regexp/$subst/;
Warning - untested. I know I've used code similar to this in the past with a limited amount of success. (i.e., it worked for me for what I needed it to work for, and this is not a cut&paste job of that code.)