Validating number in perl
Asking for untainting of a reference value will not do anything, as By default, parameters are assumed to be mandatory unless specified as optional.
I ONLY want 6 digits so when i type 7 digits the script should no validate the number.
If it's not then it calls the same sub-routine until a validating entry is matched.
However, even if the input is between 1-99 it will keep calling the sub routine.
The callback will be given the value of the parameter as its first argument.
Its second argument will be all the parameters, as a reference to either a hash or array. The key is an id for the callback (used in error messages) and the value is a subroutine reference, such as: This will untaint the "foo" parameter if the parameters are valid.
Search for validating number in perl:
Here are some precooked solutions (the Cookbook's equivalent of just-add-water meals) for most common cases: warn "has nondigits" if /\D/; warn "not a natural number" unless /^\d $/; # rejects -3 warn "not an integer" unless /^-? \d*$/; # rejects .2 warn "not a decimal number" unless /^-? General documentation for the module can be found in the Regexp:: Common manpage, but more detailed documentation for just the numeric patterns is in the Regexp:: Common::number manpage.