wrote:
> How do I find out if a string is uppercase only? I've searched cpan for
> a suitable module, but found nothing.
> This is what I'm looking for:
> is uppercase("UPPERCASE ") # TRUE
> is uppercase("UPPERCaSE ") # FALSE
I believe this should do the trick:
----------------------------------------------------
#!/usr/bin/perl
$isUppercase="OK";
$string="PUTSOMETESTSTRINGHERE";
@splitit = split //, $string;
for (@splitit) {
$isUppercase = "not OK"
if ($_!~/(A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y |Z)/)
}
print "Upper case: $isUppercase";
----------------------------------------------------
You can extend the (A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y |Z)
part to include the Swedish characters that you want to allow. (or if
you want spaces as in your example, etc)
hope this helps
Bart