Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Interpolating backreferences in an eval

by gone2015 (Deacon)
on Feb 11, 2009 at 17:11 UTC ( [id://743111]=note: print w/replies, xml ) Need Help??


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 ;

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://743111]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found