Serge314 has asked for the wisdom of the Perl Monks concerning the following question:

I'm surprized with \L, \l, \U and \u, are you too? :-)

Does the operators \L \l \U and \u have right to left associativity, or vice versa?
I think, the operators must have right to left associativity as =.
Have the operators such property as a priority?

print "\u\LdD\n"; # Dd It seems, first works \L, then \u. Good. print "\u\la\n"; # A First \l, then \u. Good! print "\l\ua\n"; # a First \u, then \l. Good!! print "\L\udD\n"; # Dd It seems, first works \L, then \u, hm... print "\LdD\udD\n"; # dddd It seems, first works \u, then \L, hmmm... print "\L\Ua\n"; # Syntax error print "\U\La\n"; # Syntax error print "\L\La\n"; # Syntax error print "\u\la\n"; # A All right print "\u\ua\n"; # A All right

Surprized? I'm again...
How we should understand work of these operators?
Should I submit a bug report? :-)

Replies are listed 'Best First'.
Re: I'm surprized with \L, \l, \U and \u, are you too? :-)
by Anonymous Monk on Feb 21, 2011 at 09:20 UTC
Re: I'm surprized with \L, \l, \U and \u, are you too? :-)
by ikegami (Patriarch) on Feb 21, 2011 at 08:58 UTC
    So it acts like list ops, with special rules to do the right thing when there are adjacent escapes. What would be gained by changing the behaviour? I'd suggest a documentation patch instead.
      So it acts like list ops, with special rules to do the right thing when there are adjacent escapes.

      Um, I'm not sure what you mean by that, the behavior appears inconsistent

      use Test::More qw' tests 2 '; is( "\LA\uA", "??", '\LA\uA' ); is( "\L\uAA", "??", '\L\uAA' ); __END__ 1..2 not ok 1 - \LA\uA # Failed test '\LA\uA' # at crap line 2. # got: 'aa' # expected: '??' not ok 2 - \L\uAA # Failed test '\L\uAA' # at crap line 3. # got: 'Aa' # expected: '??' # Looks like you failed 2 tests of 2.
      The way I read perlop they should both result in aa. Or to be a consistent special case, both should result with one character uppercased.
        \L\u makes no sense (would be the same as just \L), so Perl treats it as \u\L (which was surely the intended effect).
        To clarify , if as perlop states
        "\Q\t\E" is converted to quotemeta("\t"),
        shouldn't both
        "\LA\uA" be converted to lc( "A\uA" ) "\L\uAA" be converted to lc( "\uAA" )