[Chicago-talk] detecting whether a scalar is number or a string.

Richard Reina richard at rushlogistics.com
Sun Jul 6 17:41:37 PDT 2008


Thanks for the reply but when I try:

$string = "859684";

if ($string =~ m/[:digit:]/) {
    print "this is numeric\n";
}

I get:

POSIX syntax [: :] belongs in character classes regex;


---- Chicago.pm chatter <chicago-talk at pm.org> wrote:
>
> On Sun, Jul 6, 2008 at 2:48 PM, Richard Reina <richard at rushlogistics.com> wrote:
> > Hello and Happy Sunday to All,
> >
> > Can someone tell me please how I can test whether a string is number or not.
> >
> > so to differentiate from:
> >
> > my $string = "anssds";
> >
> > and
> >
> > $string = "5879873454";
> >
> > Thanks for your attention.  Have a great day!
> > _______________________________________________
> 
> $string =~ m/[:digit:]/;
> -or-
> $string =~ m/[:alpha:];
> 
> -- 
> shawn.c.carroll at gmail.com
> Perl Programmer
> Soccer Referee
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
> 


More information about the Chicago-talk mailing list