Monks, I thought \Q and \E in regexes means no interpolation happens, like the equivalent of '' for strings. But I guess I was wrong about that as the following snippet shows. Or is there indeed some way to get \Q and \E to literal-match the dollar, as it literal-matches parenthesis and most other special characters? Thanks!
use strict; use warnings; use Test::More qw(no_plan); like('a',qr/a/); #passes like('(',qr/\Q(\E/); #passes -- \Q\E works for parenthesis and most sp +ecial characters like('asdf$',qr/\Qasdf$\E/); #no -- but not for the dollar sign like('asdf$',qr/\Qasdf\$\E/); #no like('asdf$',qr/asdf$/); #no like('asdf$',qr/\$/); #passes -- you have to backslash the dollar
UPDATE: Much obliged, monks. Cutting to the good part, it seems my question can best be answered with: use quotemeta, and compile the result with qr.
use strict; use warnings; use Test::More qw(no_plan); like('asdf$', quotemeta('asdf$')); #fails my $re = quotemeta('asdf$'); like('asdf$', qr/$re/); #passes like('asdf$', qr/@{[ quotemeta('asdf$') ]}/); #passes

In reply to Can I use Q and E to regex match the dollar sign? by tphyahoo

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.