http://qs321.pair.com?node_id=743111


in reply to Interpolating backreferences in an eval

Try:

print eval qq{"$to"}, "\n";
...eval comes in two flavours: (a) eval BLOCK -- in which the BLOCK is compiled in the usual way, and the eval is a way of trapping die; (b) eval EXPR in which the result of the EXPR is parsed and executed at run time. See expr.

Of course, you could also:

my $q = $1 ; $to =~ s/\$1/$q/g ;