Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Regexp substitution using variables

by Bod (Parson)
on Nov 25, 2020 at 22:03 UTC ( [id://11124229]=note: print w/replies, xml ) Need Help??


in reply to Re: Regexp substitution using variables
in thread Regexp substitution using variables

Even string eval doesn't help, as plain interpolation of the $replacement can break if it contains a slash

My first thought was to use eval but I hit a brick wall when I tried...
I was thinking of first changing a slash in $replacement for a double slash then using eval to do the substitution but I got stuck getting the result of the substitution.

$replacement =~ s/\\/\\\\/g; $string =~ eval "s/\$pattern/\$replacement/$flags";
But that doesn't do it...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124229]
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: (3)
As of 2024-04-19 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found