http://www.perlmonks.org?node_id=741942


in reply to Evaluating $1 construct in literal replacement expression

How about:

my $s ; s/$search/$subst/g and $s = $1 and s/\$1/$s/g ;