Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Interpolating backreferences in an eval

by Anonymous Monk
on Feb 11, 2009 at 17:23 UTC ( [id://743114]=note: print w/replies, xml ) Need Help??


in reply to Interpolating backreferences in an eval

sub expand { my ($rx, $from, $to) = @_; if ($from =~ /$rx/) { print (eval $to)."\n"; } } #expand(qr/a(.)c/, 'abc', 'a$1$1c'); expand('a(.)c', 'abc', "a$1$1c");

Replies are listed 'Best First'.
Re^2: Interpolating backreferences in an eval
by ikegami (Patriarch) on Feb 11, 2009 at 17:28 UTC

    For it to run, that should be

    expand(qr/a(.)c/, 'abc', '"a$1$1c"');

    or

    print (eval qq{"$to"})."\n"; expand(qr/a(.)c/, 'abc', 'a$1$1c');

    But oh so wrong.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-05-21 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found