in reply to Re: Recognizing all-caps line
in thread Recognizing all-caps line

Happy-the-monk has it right, that this is better done by posix character classes rather than enumerated-alphabet character classes. The problem with a [A-Z] character class is that it may exclude some perfectly legitimate upper-case characters in non-ASCII character encodings.

The solution is POSIX character classes that do understand what constitutes an upper-case character in non-ASCII character encoding.

There are a couple errors in Happy's response though. First, [:lower:] should be [:upper:] in order to match upper case characters, as the OP's question asked. Update: Looks like that first problem was fixed in an update.

Second, the POSIX character class identifier has to be placed inside of a character class, leading to what might seem like a little bit of a wierd syntax, but is nevertheless necessary. Hense, the following:

m/^[:upper:]+$/

... will fail to match, and will generate a warning if use warnings is active (Updated), whereas ...

m/^[[:upper:]]$/

will do what you want.


Dave