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


in reply to Re^2: Regular expression "replace string interpolation" problem
in thread Regular expression "replace string interpolation" problem

Or how to embed " in the output - but that's not a biggie right now.

You want to produce the code
"$1 \"Perl\""
so
my $replace = '"$1 \\"Perl\\""'; # Produces: "$1 \"Perl\"" s/$match/eval $replace/e

Technically, the slashes don't need to be doubled since single quotes are forgiving when it's unambiguous.