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.