in reply to Interactions of \Q, \U, \L and \E

They work at a very low level. In the tokeniser, I believe. That would explain why they fail if you do anything odd with them, such as follow a \Q with a \U
>perl -e"print qq{\Q\U,a}" \,A

(\Q doubled \U's slash without realising it was part of an escape.)

In my opinion, they are primarily meant to be used when followed by a variable.

Update: Oops, it's actually working right. The "\" is for the comma. I wasn't awake yet :(

Replies are listed 'Best First'.
Re^2: Interactions of \Q, \U, \L and \E
by ig (Vicar) on Aug 25, 2009 at 15:02 UTC

    Yes, they are handled in the tokeniser. It was while reading the tokeniser code that I became confused/curious about how they operate and why.

    In the case of qq(\Q\U,a) this is equivalent (converted to) quotemeta(uc(',a')), as can be seen from the following:

    Having further reviewed the tokeniser code, I am reasonably certain how these escapes are handled but still wondering if there is documentation other than that in perlop. I would be particularly interested to understand the cases/situations in which the inconsistencies are necessary or beneficial. I am guessing there are such cases as it would have been significantly simpler to implement, document and understand without the inconsistencies.