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
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
"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
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
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+\.?\
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
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
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
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
: }
:
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
>> 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
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 two - signs.
Thanks for
12 matches
Mail list logo