Re: isNumber( ) ??

2001-10-20 Thread Bernie Cosell
Meta question about 'isNumber()' --- should it return true or false for the string 0 but true. As far as Perl is concerned that *is* a number, right? :o) /Bernie\ -- Bernie Cosell Fantasy Farm Fibers mailto:[EMAIL PROTECTED] Pearisburg, VA -- Too many people

Re: isNumber( ) ??

2001-10-20 Thread Philip Newton
On Fri, 19 Oct 2001 18:05:54 +0100, [EMAIL PROTECTED] (Piers Cawley) wrote: #!/usr/bin/perl6 sub is_number ($number) { return +$number eq 'NaN' } s/eq/ne/ ? Cheers, Philip

Re: isNumber( ) ??

2001-10-19 Thread Piers Cawley
Selector, Lev Y [EMAIL PROTECTED] writes: 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

Re: isNumber( ) ??

2001-10-19 Thread Robert C. Helling
On Fri, 19 Oct 2001, Philippe 'BooK' Bruhat wrote: On Fri, 19 Oct 2001, Matt Bernstein wrote: how about ($x+0 eq $x) (rather untested) perl -ne 'chomp;print+($_+0eq$_)?:NOT,a number\n' Stupid question: Is 1.00 a number? Robert --

Re: isNumber( ) ??

2001-10-19 Thread Ian Phillipps
On Thu, 18 Oct 2001 at 20:43:40 -0400, Uri Guttman wrote: 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. :) Oh, I don't know. My solution is a few strokes better than the FAQ's :-)

Re: isNumber( ) ??

2001-10-19 Thread Uri Guttman
IP == Ian Phillipps [EMAIL PROTECTED] writes: IP On Thu, 18 Oct 2001 at 20:43:40 -0400, Uri Guttman wrote: 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. :) IP Oh, I

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
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

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
Selector -Original Message- From: Josh Goldberg [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 18, 2001 6:47 PM To: Selector, Lev Y Cc: '[EMAIL PROTECTED]' Subject: Re: isNumber( ) ?? On Thu, 18 Oct 2001, Selector, Lev Y wrote: Any recommendations? something like

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 .*?