\L, \U, \Q, \l and \u are dealt with during
parsing of a quoted construct, which takes up to five passes:
- Find the end of the quoted construct.
- Removal of backslashes before delimiters.
- Interpolation (this is where \L and friends processing happens)
- Interpolation of regular expressions.
- Optimization of regular expressions.
For details, see the section
Gory details of parsing quoted constructs in the perlop manual page.
So, by the time the regex engine gets the string, any \L it finds it treats is as an escaped L - which will trigger a warning.
Strings gotten from the environment, like program parameters, are never parsed as quoted constructs (unless you 'eval' them).