Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Evaluating $1 construct in literal replacement expression

by balakrishnan (Monk)
on Feb 06, 2009 at 14:48 UTC ( [id://741900]=note: print w/replies, xml ) Need Help??


in reply to Evaluating $1 construct in literal replacement expression

Using eval, you can achieve your need,
$_=q{nell'amaca}; my $search=q{nell'([[:alpha:]]+a)}; my $subst='na $1'; $expr = "s/$search/".eval $subst."/g"; eval $expr; print; print "\n";
First we are constructing the substitution, in that using the eval, the substitute pattern is evaluated. And then the total substitution has been evaluated.

I hope this would match your requirement.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-06-14 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.