Try either of the following:

$line =~ m/^[[:upper:]]+$/    # or
$line =~ m/^\p{IsUpper}+$/

the [: ... :] is no character class, although it looks like one.
To make it (part of) a character class, you need another set of brackets around it.

don't go for   m/^[A-Z]+$/   for world peace international reasons ;-)
See   perldoc perlre   too.

Update: You might find the double negation more convenient:

$line !~ m/[[:^upper:]]/    # or
$line !~ m/\P{IsUpper}/

(think: do not match a line that contains anything that's not an uppercase letter)


Edit: corrected a number of mistakes.
Thanks especially to davido(++) for pointing out the ones I didn't find myself. Strange enough, while the necessity of the double brackets is not in doubt, I don't get any warnings when omitting them (perl5.8.3, Linux), the code just never tests true.
Another Edit: I guess that's because it looks like a character class to Perl. So why did it throw errors when davido tried it?
Another edit (and moved this discussion to the bottom of the node) -
I tried   m/[:^upper:]/;   which bypasses warnings.
Congratulations to us, we found a bug.

Cheers, Sören


In reply to Re: Recognizing all-caps line by Happy-the-monk
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.