I recently banged my head on exactly this problem, and tye pointed out that Perl has it own internal routine for deciding whether a scalar is a valid number.
It seems a shame that this internal routine is not exposed to the programmer, and I made an attempt to gain access to it (under AS) using Win32::API to access the internal routine looks_like_number() function in perl56.dll directly. Unfortunately, it proved impossible (for me anyway) to gain access to the address of a scalar in a form that it would accept from within perl. Tye kindly tracked this down to being something to do with it needing a thread-safe verion of the pointer.
I believe that it would be possible to write a small XS module to expose the function, which would make a lot more sense than everyone having to rewrite it's logic using regexs or whatever, but I am not yet ready to go delving into the excesses of XS.
Any takers?
Maybe they will expose it in a later version of Perl. Who knows.
In reply to Re: Parse float from string
by BrowserUk
in thread Parse float from string
by gryphon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |