Watch out, though. It is working on the question you asked in the text of your post with the 3 examples you gave (because only the 1st sentence has a capital U), it is not a valid answer to the more general question in the title of your post. For this more general question, I would rather suggest something like this:

print if $_ eq uc $_;

Or yet simpler:

print if $_ eq uc;

UPDATE: following polypompholyx's answer, I just want to clarify that my first answer was sort of a practical joke, something that would work fine in the specific case you presented (the question as asked in the original post and the example), but would most probably not do what you really wanted, the reason being that the question was very poorly defined (an example is very rarely a good specification). When I saw that you seemed to have bought it, I felt compelled to correct this false impression, with the above post and a real solution. The two code snippets above probably do what you want (in the right context), my first post did *not*, it worked only in the specific case of your example. As polypompholyx said, my idea was to try to let you think about why it would work with your example, but most probably not do you are looking for. Think about it, an example is usually very useful, but it is never a substitute for a good spec.


In reply to Re^3: print only uppercase sentences by Laurent_R
in thread print only uppercase sentences by lakssreedhar

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.