| Paul Lalli 2006-03-21, 9:55 pm |
| Baldoni wrote:
> Paul Lalli wrote:
>
>
> So sorry to disagree. http://www.perl.com/doc/FMTEYEWTK/is_numeric.html
I have no idea what you think that article told you that makes you
disagree with what I said about your current situation.
The article is simply about converting a string that possibly has
garbage into a number. It has nothing to do with verifying the input
to a CGI form.
As an aside, that article needs some work:
do {
print "Number, please: ";
$answer = <STDIN>;
print "Bad number\n" if $answer == 0;
} until $answer;
That code, when presented with user input of 'foobar', will print out
"Bad number\n" once, and then terminate the loop, leaving $answer as
'foobar'. I have no idea what the author thought that would
accomplish.
I would also like to point out that as far as verifying numbers is
concerned, you would be better off not relying on a document written
(literaly) a decade ago. Instead, consider the CPAN module
Regexp::Common.
Paul Lalli
|