Re: isNumber( ) ??

2001-10-18 Thread Peter Scott
At 01:19 AM 10/19/01 +0100, Ian Phillipps wrote: On Thu, 18 Oct 2001 at 18:33:53 -0400, Selector, Lev Y wrote: Wow! This is really elegant !! -Original Message- From: Josh Goldberg [mailto:[EMAIL PROTECTED]] sub isNumber { !/\d/ ? 0 : $_ == 0 ? 1 : $_ * 1 } Possibly

Re: isNumber( ) ??

2001-10-18 Thread Uri Guttman
IP == Ian Phillipps [EMAIL PROTECTED] writes: IP I feel sure this is a FAQ... trust your feelings. i didn't answer because it IS an FAQ. FAQ's aren't fun. :) perldoc -q number How do I determine whether a scalar is a number/whole/integer/float? uri -- Uri Guttman

Re: isNumber( ) ??

2001-10-18 Thread Michael G Schwern
On Thu, Oct 18, 2001 at 04:49:56PM -0400, Selector, Lev Y wrote: 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). When in doubt, ask Perl.

Re: isNumber( ) ??

2001-10-18 Thread Ira Joseph Woodhead
True enough, I thought I had been booted off the list or something... Just wanted to comment, that if you roll your own number detector, and you want it compatible with *nix Perl, you should count as a number any string beginning with letters inf (case insensitive). This is an undocumented

Re: isNumber( ) ??

2001-10-18 Thread Josh Goldberg
On Thu, 18 Oct 2001, Selector, Lev Y wrote: Any recommendations? something like this perhaps? ns21# cat t.pl #!/usr/bin/perl sub isNumber { !/\d/ ? 0 : $_ == 0 ? 1 : $_ * 1 } for ( qw[ 0 abcdefg 1 -1.0 1.0e-10 10abc ] ) { print $_ - , isNumber($_), \n; } ns21# perl t.pl 0 -

RE: isNumber( ) ??

2001-10-18 Thread Josh Goldberg
there is the perlish behaviour done with 10abc... if you give it 12abc34 it returns 12. may or may not be expected output... but thanks! first time poster, long time lurker. On Thu, 18 Oct 2001, Selector, Lev Y wrote: Wow! This is really elegant !! Warmest Regards Lev

Re: isNumber( ) ??

2001-10-18 Thread Craig S . Cottingham
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thursday, October 18, 2001, at 09:03 , Michael G Schwern wrote: When in doubt, ask Perl. sub is_num { my($cand) = shift; my $not_num; local $^W = 1; local $SIG{__WARN__} = sub { $not_num = $_[0] =~ /^Argument .*?