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

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.
  • Comment on Re: I'm surprized with \L, \l, \U and \u, are you too? :-)

Replies are listed 'Best First'.
Re^2: I'm surprized with \L, \l, \U and \u, are you too? :-)
by Anonymous Monk on Feb 21, 2011 at 09:46 UTC
    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).
        \L\u makes no sense (would be the same as just \L)

        $foo + 1 - 1 might not make sense either, but that is completely irrelevant, it should work as advertised

        so Perl treats it as \u\L (which was surely the intended effect).

        How would you know if it was the intended effect? If there were such a bizzare exception, surely it would be documented.

      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" )