Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Side effects of an /e modifier

by k-mx (Scribe)
on Jan 29, 2020 at 17:17 UTC ( [id://11112028]=note: print w/replies, xml ) Need Help??


in reply to Side effects of an /e modifier

Yet another solution (:

You can eval random code inside (?{ }) and use result with variable $^R

$bar =~ s#\d{2}(?{ $& * 5})#<td>$^R</td>#gms;

More information:

perldoc -v '$^R' perldoc -v '$&' perldoc perlre

And I want to point, that you don't need to capture whole match. It will already situated in $&

P.S.

I should have said, that there is global performance penalty for using $& somewhere in your code. It was fixed only in 5.020

Please read following documentation for more information:

perldoc perlfaq6 perldoc perlvar

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-19 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found