Folks, It was long time - no messages (on this list). Is everybody OK? I am working in downtown New York City - and still can smell burning outside the building:
http://www.spaceimaging.com/ikonos/wtc0915_1280.jpg I have a (simple) Perl question. Is there a standard function in perl which can tell me if a string represents a valid number? (including integer, with decimal point and scientific notaion with "e"). Of course, I can write one myself. For example, something like this (if we are not considering hex, octal and binary): # --------------------------------------------- sub isNumber { my $ss = shift; return 1 if $ss =~ /^[+\-]?\d*.?\d+$/; return 1 if $ss =~ /^[+\-]?\d*.?\d+e[+\-]?\d+$/i; return 0; } for ( qw[ 1 -1.0 1.0e-10 10abc ] ) { print "$_ -> ", isNumber($_), "\n"; } # --------------------------------------------- But may be there is a standard solution already? POSIX module has several functions. For example, isdigit returns 1 if argument consists only of digits. This covers only integer numbers. There are other functions, like strtoi, strtol, strtod to convert a string to integer, long, or double. But these functions are specific to their nubmer type. What I need is a combination of them. Any recommendations? Warmest Regards ---- Lev Selector New York, t. 212-902-3040
