in reply to Interpolating backreferences in an eval


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 ;

Replies are listed 'Best First'.
Re^2: Interpolating backreferences in an eval
by gnustavo (Novice) on Feb 11, 2009 at 19:05 UTC

    Thanks you! It works.

    I've tried eval "$to" but got a syntax error that I couldn't understand. Seeing that eval qq{"$to"} is the same as eval "\"$to\"" I can understand now what I've done wrong.