"be consistent" | |
PerlMonks |
Validating Numbers in CGI Script?by footpad (Abbot) |
on May 10, 2001 at 07:30 UTC ( [id://79320]=perlquestion: print w/replies, xml ) | Need Help?? |
footpad has asked for the wisdom of the Perl Monks concerning the following question: The apprentice, after taking aspirin for the pain in his forehead, finally caves after several hours... Some time ago, a certain monk (privately) advised the following after seeing my poor attempts to verify that a certain CGI parameter was actually a number, e.g. a non-blank, Base-10 numeric value that may (or may not) contain decimal points and/or hyphens masquerading as negative number indicators: Best perlop check? Try this: eval {local $^W = 1; $num + 0}; # Now check $@ Okay. So I'm trying to suit the action to these words and am not having much success:
As the more experienced of you will recognize, this is resulting in values such as "20" as being recognized as a number. Sadly, so are "Shoe", "Fred" and other patently non-numeric values, by which (just to be perfectly clear to the most rententive) are *not* numeric in the locale, idiom, and operational parameters that I'm trying to communicate in. My petitions are:
Yes, I am aware of the Cookbook and its examples; you'll note this monk had a different approach in mind. I'm trying to get it to work. A gentle nudge would be greatly appreciated. Many thanks in advance... --f
Back to
Seekers of Perl Wisdom
|
|