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

Re^2: String substitution

by AnomalousMonk (Archbishop)
on Sep 20, 2016 at 02:56 UTC ( [id://1172200]=note: print w/replies, xml ) Need Help??


in reply to Re: String substitution
in thread String substitution

$str =~ s/.*nr(\d+)([^\d]+)(\d+)(.*)/"calc(nr$1)$2".eval{$3*4}."$4";/e;

FWIW: The separate  eval{$3*4} is not needed (although it does no harm) because the entire replacement expression is already being eval-ed:
    $str =~ s/.*nr(\d+)([^\d]+)(\d+)(.*)/"calc(nr$1);$2" . $3*4 . $4/e;
(tested, and I also stuck the semicolon back where kepler seems to want it).


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found