in reply to Perldoc: String interpolation with octal escpape sequence like "\1"

perlop under Quote and Quote like Operators

The following escape sequences are available in constructs that interpolate, and in transliterations:

...

\033 [7,8] restricted range octal char (example: ESC)

...

Some contexts allow 2 or even 1 digit, but any usage without exactly three digits, the first being a zero, may give unintended results.

...

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
  • Comment on Re: Perldoc: String interpolation with octal escpape sequence like \1
  • Download Code

Replies are listed 'Best First'.
Re^2: Perldoc: String interpolation with octal escpape sequence like \1
by Eily (Monsignor) on Oct 02, 2018 at 15:18 UTC

    Also:

    Starting in Perl 5.14, you may use \o{} instead, which avoids all these problems. Otherwise, it is best to use this construct only for ordinals \077 and below, remembering to pad to the left with zeros to make three digits.
    Basically "Don't do it". The confusion with \1 and so on being the main reason IMHO.

      > Basically "Don't do it".

      "Don't do it"* doesn't mean document it badly, especially if there is no warning.

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

      *) BTW I agree!

Re^2: Perldoc: String interpolation with octal escpape sequence like \1
by LanX (Saint) on Oct 02, 2018 at 15:29 UTC