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

Steven Lembark lembark at wrkhors.com
Mon Jul 7 14:04:45 PDT 2008


> my $string = "anssds";
>  
> and 
> 
> $string = "5879873454";

       use Scalar::Util qw( looks_like_number );

       if( looks_like_number $scalar )
       {
             # perl will do math on it.
       }
       else
       {
             # perl will not do math on it.
       }


More information about the Chicago-talk mailing list