XP is just a number | |
PerlMonks |
Re: How to best filter/direct data based on input structure?by Kenosis (Priest) |
on Nov 02, 2013 at 03:13 UTC ( [id://1060877]=note: print w/replies, xml ) | Need Help?? |
Hi Chris. This is not a stupid question. Consider using a couple of modules for the validation tasks, viz., Regexp::Common (for IP addresses) and Data::Validate::Domain. Given these, you can do the following:
Output:
The validation results are generated using the ternary operator and the modules' offerings: $input is returned if it's a valid IP or domain; anything else returns $form. Hope this helps!
In Section
Seekers of Perl Wisdom
|
|