Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: undocumented tr special behavior for single-quoted transform

by LanX (Bishop)
on Jan 06, 2018 at 10:33 UTC ( #1206809=note: print w/replies, xml ) Need Help??


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

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: note [id://1206809]
    help
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (2)
    As of 2018-01-21 11:13 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How did you see in the new year?










      Results (227 votes). Check out past polls.

      Notices?