in reply to Form validation

When I saw this post, I thought to myself that there must be a module that validates that a string has the right form to be a URL (without actually trying to use the string to connect). But I couldn't find one. If you're looking for a "good enough" solution, something like what cianoz proposes would be a start. It depends how nit-picky you're going to be. You might want to make sure there's a protocol ID in the string, and at least one period surrounded by other valid, non-period characters (although http://localhost is valid and won't fit that, so even *that's* not guaranteed). I'm not enough of a regex genius to make that happen (yet), and I don't have the RFC handy. So the following comes with heaps of disclaimers. Hopefully, it will get you started and won't damage your career as a Perl programmer or a human being =)

# since this is messy and we need to use it a bunch of times, let's lo +ad it into a scalar. my $val = "[a-z0-9?]+=\-%"; # there is no way in heck this is correct; + it's a *beginning* though # get input if (is_url($string)) { # do something with it } ... sub is_url { my $input = shift; $input =~ #(?:http(?:s)|ftp)://$val+\.$val+#i; }
HTH

Philosophy can be made out of anything. Or less -- Jerry A. Fodor