Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: print only uppercase sentences

by lakssreedhar (Acolyte)
on Aug 04, 2013 at 14:28 UTC ( [id://1047795]=note: print w/replies, xml ) Need Help??


in reply to Re: print only uppercase sentences
in thread print only uppercase sentences

yes its working

Replies are listed 'Best First'.
Re^3: print only uppercase sentences
by polypompholyx (Chaplain) on Aug 04, 2013 at 15:43 UTC

    Unfortunately,

    print if /O/;

    will also 'work' on your sample data, and for the same reason. zork42's post is probably the answer to your short-term problem; but rjt's links, and thinking carefully about why Laurent_R's post is almost certainly *not* what you're after would probably be a lot more useful to you in the long-term.

Re^3: print only uppercase sentences
by Laurent_R (Canon) on Aug 04, 2013 at 15:39 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1047795]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-20 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found