Re: checking if its a real number

2003-03-04 Thread Janek Schleicher
On Wed, 26 Feb 2003 19:47:35 -0500, Casey West wrote: > Here's a nice trick. Use the int() function. It's documented in > perlfunc, a short to the documentation is 'perldoc -f int'. > > When passed a string, int() will return 0. When passed a number, it > will return the integer version of tha

Re: checking if its a real number

2003-03-04 Thread Janek Schleicher
On Wed, 26 Feb 2003 16:30:56 -0800, T. Murlidharan Nair wrote: > Is there a quick and easy way to check this. I was trying using a reg exp > if(/^[-0-9][\.0-9]*/) { > do something > } In CPAN there's also a module Regexp::Common that has a lot of commonly requested regexps. E.g. also $RE{num}{re

Re: checking if its a real number

2003-03-03 Thread Todd Wade
"Casey West" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > It was Wednesday, February 26, 2003 when Robert Wideman took the soap box, saying: > : >> I have a cgi that need to accept only numeric values. ie +ve or -ve > : >> real numbers. > : >> Is there a quick and easy way to ch

Re: checking if its a real number

2003-02-27 Thread T. Murlidharan Nair
Thanks to all for replying to my questions. Cheers always!! Murli zentara wrote: On Wed, 26 Feb 2003 16:30:56 -0800, [EMAIL PROTECTED] (T. Murlidharan Nair) wrote: I have a cgi that need to accept only numeric values. ie +ve or -ve real numbers. Is there a quick and easy way to check this. I

Re: checking if its a real number

2003-02-27 Thread Felix Geerinckx
on Thu, 27 Feb 2003 13:34:40 GMT, [EMAIL PROTECTED] (Zentara) wrote: > if (/\D/){ print "has nondigits\n" } > if (/^\d+$/) { print "is a whole number\n" } > if (/^-?\d+$/) { print "is an integer\n" } > if (/^[+-]?\d+$/){ print "is a +/- integer\n" } > if (/^-?\d+\.?\

Re: checking if its a real number

2003-02-27 Thread zentara
On Wed, 26 Feb 2003 16:30:56 -0800, [EMAIL PROTECTED] (T. Murlidharan Nair) wrote: >I have a cgi that need to accept only numeric values. ie +ve or -ve >real numbers. >Is there a quick and easy way to check this. I was trying using a reg exp >if(/^[-0-9][\.0-9]*/) { > do something >} > >but thi

Re: checking if its a real number

2003-02-27 Thread Gary Stainburn
If you want to check for real numbers, try something like the demo script below. '-12.3' shows true while '--12.3' shows false. HTH Gary #!/usr/bin/perl my $fred='-12.3'; $fred+=1; $fred-=1; $resp= ($fred) ? "$fred is numeric\n" : "$fred is not numeric\n"; print $resp; On Thursday 27 Feb

Re: checking if its a real number

2003-02-27 Thread Casey West
It was Wednesday, February 26, 2003 when Robert Wideman took the soap box, saying: : >> I have a cgi that need to accept only numeric values. ie +ve or -ve : >> real numbers. : >> Is there a quick and easy way to check this. I was trying using a reg exp : >> if(/^[-0-9][\.0-9]*/) { : >> do somet

Re: checking if its a real number

2003-02-27 Thread Casey West
It was Wednesday, February 26, 2003 when T. Murlidharan Nair took the soap box, saying: : I have a cgi that need to accept only numeric values. ie +ve or -ve : real numbers. : Is there a quick and easy way to check this. I was trying using a reg exp : if(/^[-0-9][\.0-9]*/) { : do something : } :

Re: checking if its a real number

2003-02-27 Thread Felix Geerinckx
on Thu, 27 Feb 2003 00:30:56 GMT, [EMAIL PROTECTED] (T. Murlidharan Nair) wrote: > I have a cgi that need to accept only numeric values. ie +ve or > -ve real numbers. > Is there a quick and easy way to check this. This is a FAQ. See perldoc -q float -- feliex -- To unsubscribe, e

RE: checking if its a real number

2003-02-26 Thread Robert Wideman
>> I have a cgi that need to accept only numeric values. ie +ve or -ve >> real numbers. >> Is there a quick and easy way to check this. I was trying using a reg exp >> if(/^[-0-9][\.0-9]*/) { >> do something >> } >> >> but this breaks when the number is say --75.4 It still accepts if it >> has