Due to the way the single-quote string constructor handles backslashes (escapes), the \\ will in this case compile to a single literal backslash. See Quote and Quote-like Operators and the discussion of q/STRING/ in Quote-Like Operators.

Thanks for your comment, AM. Your link is a good read and worth reposting. I thought that the collapsing of backslashes was done by the OS in resolving paths. I was unaware that perl did it.

do you dispute that there is a left-curly (and a right-curly) in the \x{A3f4} string? What else would you call it/them?

I do not dispute that, so this string itself never represents a left curly brace, rather it has a left curly brace in it.

I would call it (or in this case \x{A3f4}) "the string compiled from '\\x{A3f4}'"

Ok. From the above source we have:

\x{263A} [1,8] hex char (example shown: SMILEY) \x{ 263A } Same, but shows optional blanks inside and adjoining the braces \x1b [2,8] restricted range hex char (example: ESC)

So, I think "aha, it's a hex representation", but then I can't get there with the REPL:

DB<1> $str2='\\x{263}' + DB<2> p $str2 + \x{263} DB<3> p hex $str2 + 0 DB<4> print hex $str2 + 0

I would expect to see a smiley face rather than zero. This is a head-scratcher:

DB<6> $str3='\\\\\\\x{aF}' + DB<7> p $str3 + \\\\x{aF} DB<8> p hex $str3 + 0 DB<9> print hex $str3 + 0

$str3 goes from 7 to 4 backslashes when compiled(?). But I get zero for a hex value no matter what I try:

DB<10> $str4='\x{aF}' + DB<11> p $str4 + \x{aF} DB<12> print hex $str4 + 0 DB<13> print hex 'aF' + 175

How do I tease 175 out of $str4?

The \x part has nothing to do with the /x or /xx regex modifiers.

That part is clearer now. I have that backslash/forwardslash disphoria going on now where I can hardly see the difference and it looks like a toothpick war. I get the occasional billiken that I read or write the wrong way.


In reply to Re^6: Unescaped left brace in regex is passed through in regex by Aldebaran
in thread Unescaped left brace in regex is passed through in regex by gzh

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.