shorter example

interpolation, the \Q\E is interpolated in double quoted strings

$ perl -Mre=debug -e " $f=q{a??q}; $f =~ m{\Qa??\E}; " Compiling REx "a\?\?" Final program: 1: EXACT <a??> (3) 3: END (0) anchored "a??" at 0 (checking anchored isall) minlen 3 Guessing start of match in sv for REx "a\?\?" against "a??q" Found anchored substr "a??" at offset 0... Guessed: match at offset 0 Freeing REx: "a\?\?"

use qr to see how \Q\E gets interpolated

$ perl -le " print qr{\Qa??\E}; " (?^:a\?\?)

without interpolation the pattern is completely different

$ perl -le " print qr'\Qa??\E'; " (?^:\Qa??\E)

The regex metacharcters are still regex metacharacters (pattern)

$ perl -Mre=debug -e " $f=q{a??q}; $f =~ m'\Qa??\E'; " Compiling REx "\Qa??\E" Final program: 1: EXACT <Q> (3) 3: MINMOD (4) 4: CURLY {0,1} (8) 6: EXACT <a> (0) 8: EXACT <E> (10) 10: END (0) anchored "Q" at 0 floating "E" at 1..2 (checking floating) minlen 2 Guessing start of match in sv for REx "\Qa??\E" against "a??q" Did not find floating substr "E"... Match rejected by optimizer Freeing REx: "\Qa??\E"

perlrebackslash :)


In reply to Re^3: Misreading m// documentation (BUG?) by Anonymous Monk
in thread Misreading m// documentation by QM

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.