Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!perl
use strict;
use warnings;
[b]sub allcaps {
# Returns true if string contains uppercase chars and
# no lowercase chars, false otherwise.
my $str = shift;
$str =~ /[[:upper:]]/ && $str !~ /[[:lower:]]/;
}[/b]
while (<DATA>) {
chomp;
print "$_>> ", allcaps2($_)? "": "Not ", "All Caps\n";
}
__DATA__
I would like to discourage the usage of ALLCAPS.
How do I detect using perl, if someone has used ALL CAPITALS
ALL CAPITALS
for a form field input?
Thanks for your help.
HTML
1234
abc123
123ABC
ALL 365 CAPS 123
[b]Output[/b]
I would like to discourage the usage of ALLCAPS.>> [b]Not All Caps[/b]
How do I detect using perl, if someone has used ALL CAPITALS>> [b]Not All Caps[/b]
ALL CAPITALS>> [b]All Caps[/b]
for a form field input?>> [b]Not All Caps[/b]
Thanks for your help.>> [b]Not All Caps[/b]
HTML>> [b]All Caps[/b]
1234>> [b]Not All Caps[/b]
abc123>> [b]Not All Caps[/b]
123ABC>> [b]All Caps[/b]
ALL 365 CAPS 123>> [b]All Caps[/b]
#!perl
use strict;
use warnings;
my @strings = (
'This is a string.',
'this is a string.',
'this is a String.',
'Hey there.',
'hOWzit?',
'e. e. cummings',
'e. e. Cummings',
);
for (@strings) {
my $STRING = $_;
my $a=($STRING=~s/([A-Z]+)/\L$1/);
print "$_: ", $a? "All upper": "Not all upper", "\n";
}
[b]Output:[/b]
This is a string.: [b]All upper[/b]
this is a string.: [b]Not all upper[/b]
this is a String.: [b]All upper[/b]
Hey there.: [b]All upper[/b]
hOWzit?: [b]All upper[/b]
e. e. cummings: [b]Not all upper[/b]
e. e. Cummings: [b]All upper[/b]