in reply to isAlpha / isNumeric

The way you're using regex's won't get you what you want. /[a-z]+/i will match a string with one or more upper and lower case letters (in a weird way, but it works) but there's lots of other characters in the world than just A-Z and "numbers." If $a="%_!@" your code will proudly proclaim that $a is "numeric" which it isn't, at least for my definition of numeric. :-D

If what you want to do is distinguish between letters and numbers, you might try:

#!/usr/bin/perl -w my $a = "aBcdeFG"; if ($a =~ /[A-Za-z]/) { # No i modifier needed print "Alphabet\n"; } elsif ($a =~ /\d/) { # \d matches 0-9 only print "Numeric\n"; } else { print "Non-numeric, non-alphabet\n"; }

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: isAlpha / isNumeric
by Jamnet (Scribe) on Mar 23, 2001 at 10:55 UTC
    Hi Gary Blackburn,

    Thanks a lot, as I am new to Perl(<3 months), your response will surely help me get better. But I would personally request you to take a look at my 'Simple Pop3 Client' under 'Code Section' and give me your feedback

    Regards

    Joel

Re: Re: isAlpha / isNumeric
by Jamnet (Scribe) on Mar 23, 2001 at 10:59 UTC
    Hi Gary Blackburn,

    Thanks a lot for your support.

    Regards

    Joel