how to check whether for each value in array is a numeric, alphabetical or alphanumeric (Perl)

Posted by dexter on Stack Overflow See other posts from Stack Overflow or by dexter
Published on 2010-04-07T09:19:06Z Indexed on 2010/04/07 9:23 UTC
Read the original article Hit count: 332

Filed under:
|

i have array which values are user input like:

aa df rrr5 4323 54 hjy 10 gj @fgf %d

would be that array,

now i want to check each value in array

whether its numeric or alphabetic (a-zA-Z) or alphanumeric

and save them in other respective arrays

i have done:

my @num;
my @char;
my @alphanum;

my $str =<>;
  my @temp = split(" ",$str);
        foreach (@temp)
           {
                print "input : $_ \n";
                if ($_ =~/^(\d+\.?\d*|\.\d+)$/)
                    {
                        push(@num,$_);
                    }
           }

this works, similarly i want to check for alphabet, and alphanumeric values

note: alphanumeric ex. fr43 6t$ $eed5 *jh

© Stack Overflow or respective owner

Related posts about perl

Related posts about regex