Hi

I have a hard time finding this behaviour documented in perldoc.

The following example is showing that "\x" and "\xx" are interpreted as octal code points in ASCII when used in string interpolation ( with x in 0..7)

DB<25> for (0..20) { $a= eval qq{"\\$_"}; print "\\$_: ",ord($a),"\n +";} \0: 0 \1: 1 \2: 2 \3: 3 \4: 4 \5: 5 \6: 6 \7: 7 \8: 56 \9: 57 \10: 8 \11: 9 \12: 10 \13: 11 \14: 12 \15: 13 \16: 14 \17: 15 \18: 1 \19: 1 \20: 16

The best I found is: (but only after realising it's octal)

perlrebackslash#Octal%20escapes

> In some contexts, a backslash followed by two or even one octal digits may be interpreted as an octal escape, sometimes with a warning, and because of some bugs, sometimes with surprising results.

Please note that perlrebackslash is supposed to describe escape sequences in regexes and not in general string interpolations.

Additionally does s/(PATTERN)/\1/ have a very different meaning in regexes (backreference of a matching group)

Is there a better perldoc to find the behaviour in normal "strings" explained?

Any canonical / obvious starting point for "string interpolation"?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

nota bene

non octal sequences in the above example (like "\8" and "\18") will create warnings (if enabled).


In reply to Perldoc: String interpolation with octal escpape sequence like "\1" by LanX

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.