Click to See Complete Forum and Search --> : How to write a "if" loop to compare whether the


Vincent001
04-18-2003, 10:04 AM
How to write a "if" loop to compare whether the
variable $a equal to (a-z and A-Z)??

e.g.

$a="Hello"
$b="!!!"

if variable $b is not equal to (a-z and A-Z)
then
{
statement;
};

jeffmott
04-18-2003, 11:45 AM
Well, for starters, if is not a loop. And second, what exactly do you mean equal to a-z and A-Z? Do you mean if $a contains at least one letter? If so then this can be done easily with a regular expression match.if ($a =~ /[a-z]/i) {
# it has a letter
}

if ($b !~ /[a-z]/i) {
# it doesn't have a letter
}