The stupid question is the question not asked | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The information you provide makes it tough to know how to advise. Generally, we can provide better answers and more help when you provide sample code and output (including exact error messages, when relevant. See How do I post a question effectively? (and, perhaps, Writeup Formatting Tips).
So, on to your question If you're using regexen, to accept, for example, only the digital portion of '$123.45' your might want to "validate" by (grossly oversimplified) prints: 123.45 The regex above (sequentially) looks for (and if found, discards) any leading non-digit character(s), then for 0 to 3 digits, a literal dot and 0 to 2 more digits, capturing the digits and the dot. For dates, you'd be well-advised to convert the user's input to some standard form, and test that. And, genericly, you may wish to read about untainting [ Question about untainting data, Untainted done right! (esp tye's reply] and similar nodes found with search or supersearch} because much of what's discussed will be applicable to your data validation needs. BTW: the notion of ...a variable that is defined as an integer.... may be tripping you up if you're accustomed to a strongly typed language. Perl isn't. OTOH, if you mean that YOU want that $var to be an integer, see the likes of numify.... Update: minor formatting, closed <tt> tag In reply to Re: perl typecasting
by ww
|
|