Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: How to determine if something is numeric?

by mifflin (Curate)
on Jan 30, 2004 at 19:34 UTC ( #325351=note: print w/replies, xml ) Need Help??


in reply to Re: How to determine if something is numeric?
in thread How to determine if something is numeric?

we must have different versions of something.
when I run that code id get the following error

erickn@hestia:/home/erickn/wo> perl x "looks_like_number" is not exported by the Scalar::Util module Can't continue after import errors at x line 5 BEGIN failed--compilation aborted at x line 5.

line 5 is the use line

I'm using perl 5.8.0
It looks like Scalar::Util uses List::Util and that version in my system is 1.07_00
any ideas?
  • Comment on Re: Re: How to determine if something is numeric?

Replies are listed 'Best First'.
Re: Re: Re: How to determine if something is numeric?
by Limbic~Region (Chancellor) on Jan 30, 2004 at 19:41 UTC
    mifflin,
    looks_like_number was introduced in version 1.10 of Scalar::Util. The sub looks like this:
    sub looks_like_number { local $_ = shift; # checks from perlfaq4 return 1 unless defined; return 1 if (/^[+-]?\d+$/); # is a +/- integer return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # +a C float return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006 +001 and /^Inf$/i); 0; }
    As I stated in my reply - I do not think this meets your requirements because it also handles decimals, scientific notation, NaN, and Inf.

    Cheers - L~R

Re: Re: Re: How to determine if something is numeric?
by PodMaster (Abbot) on Jan 30, 2004 at 19:40 UTC
    It looks like Scalar::Util uses List::Util and that version in my system is 1.07_00 any ideas?
    Upgrade :)

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://325351]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-04-10 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?