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


In reply to Re^2: Recognizing all-caps line by davido
in thread Recognizing all-caps line by ParisR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.