LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2010, 12:38 PM   #16
Telemachos
Member
 
Registered: May 2007
Distribution: Debian
Posts: 754

Rep: Reputation: 60

Quote:
Originally Posted by syg00 View Post
Doesn't pay to presume too much - does "upper/lower case" imply "ONLY upper/lower case" ?.
Stick a non alpha (say a digit) in the test string and run the tests above ...
Ok:

Code:
#!/usr/bin/env perl
use strict;
use warnings;

my $upper  = '012 FOO9';

if ($upper eq uc($upper)) {
    print "It's uppercase.\n";
}
Output:
Code:
It's uppercase.
That's the result I would have predicted (and desired). Would you want or expect a different result?
 
Old 09-08-2014, 12:57 PM   #17
fimmer
LQ Newbie
 
Registered: Sep 2014
Posts: 1

Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by PMP View Post
To add up to all your solution, The following code should work for the problem.

Code:
my $str = "STRING\n";
if ($str !~ /[a-z]/)
{
        print "$str The string is uppercase\n";
}
else
{
        print "$str contains lowercase characters\n";
}
nice and elegant solution
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for last character in string cgraham1 Programming 14 06-11-2009 01:25 PM
[perl]How to treat string like "a b" as a single string when split? john.daker Programming 21 06-01-2009 05:57 PM
grep for string and test if successfully or not B-Boy Programming 3 02-17-2009 01:43 PM
ash test: is string A contained in string B chochem Programming 6 09-24-2008 06:59 AM
java test if string in string array is null. exodist Programming 3 02-21-2004 01:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration