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.


In reply to Re: Using a regex capture as part of a varible by Fletch
in thread Using a regex capture as part of a varible by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.