in reply to undocumented tr special behavior for single-quoted transform

Single quotes inhibit interpolation

From the same perldoc perlop#Gory-details-of-parsing-quoted-constructs

  • '' , q//, tr''', y''', the replacement of s'''

    The only interpolation is removal of \ from pairs of \\ . Therefore "-" in tr''' and y''' is treated literally as a hyphen and no character range is available. \1 in the replacement of s''' does not work as $1 .

  • HTH

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Wikisyntax for the Monastery

    • Comment on Re: undocumented tr special behavior for single-quoted transform

    Replies are listed 'Best First'.
    Re^2: undocumented tr special behavior for single-quoted transform
    by Anonymous Monk on Jan 06, 2018 at 10:45 UTC

      Thank you for pointing out what I missed. My only remaining concern is this phrase at the top of that section:

      Interpolation

      The next step is interpolation in the text obtained, which is now delimiter-independent. ...

      I think this should say "delimiter-dependent".

        Well personally I consider the perldocs to be quite messy.

        Everything is documented, but you need to be an expert to find it and cope with various styles of various authors from various eras.

        For instance I only found this part by searching for the string tr'.

        (But I knew that delimiter ' has special meanings for various operators)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Wikisyntax for the Monastery