[Chicago-talk] detecting whether a scalar is number or a string.
Elliot Shank
chicago.pm at galumph.com
Sun Jul 6 13:19:39 PDT 2008
Shawn Carroll wrote:
> On Sun, Jul 6, 2008 at 2:48 PM, Richard Reina
> <richard at rushlogistics.com> wrote:
>> 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:];
Also see Scalar::Util::looks_like_number(), which actually asks the perl VM.
More information about the Chicago-talk
mailing list