in reply to Using a regex capture as part of a varible
Never used it but looking at the source I'm not sure that it'll do what you want. Your second argument is getting passed in as $replace into this bit of code:
else { @content = split( /\n/, cat($file) ); for (@content) { s/$search/$replace/; } }
You've tried to quote things correctly, but for that to work there'd need to be an /ee modifier on the substitution to get it evaluate the contents of $replace and then replace with what that expanded text contains. Unless there's some new dark magic I'm not aware of for expansions that lets you turn on /ee at a distance I don't think it's capable of what you're trying to do.
Edit: Aah you've got the multiline option set; the substitution would be the similar s///mgs a few lines earlier but the problem remains the same (it'd need to be s///mgsee to expand $replace and then evaluate the expanded value).
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a regex capture as part of a varible
by nysus (Parson) on May 07, 2020 at 14:49 UTC | |
by hippo (Archbishop) on May 07, 2020 at 15:05 UTC |