taint has asked for the wisdom of the Perl Monks concerning the following question:
I've been struggling with this problem for far too long. I seem to get real close. But for some reason, I'm missing a piece of the puzzle, I think. This is probably (should be) simple. :(
I'm attempting to provide 1 text input form field in a web page. The input has 2 choices; IP address, or Domain name. The problem I have is creating a working/effective matching scheme. I think I have all the bits. But I can't seem to focus wide enough to see the whole picture, and put the bits together. Here are the bits/logic I'm attempting to use
Yea, I know. Pretty much worthless. But even complete examples were worthless -- they didn't work. :(#!/usr/bin/perl -w use strict; # seems like an RE might be the easiest use Data::Validate::IP qw(is_ipv4); use Data::Validate::Domain qw(is_domain); # the forms text input name is,not surprisingly, input my $ip = param("input")||""; my $dom = param("input")||""; print qq( <form method="post" action="tester.cgi"> <label for="input">Input: </label><input type="text" name="input" valu +e="" /> <input type="submit" value="Post Input" /> </form>); # how do I know, how can I match? if (is_ipv4($ip)) { print "Looks like an ipv4 address"; }elsif (is_domain($dom)) { print "Looks like a domain\n"; }else{print "We got nadda";}
Apologies for the mess. But, at this point, that's what my head is.
--Chris
Hey. I'm not completely useless. I can be used as a bad example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: All attempts to match data from input fail. Please help.
by Your Mother (Archbishop) on Dec 07, 2013 at 03:04 UTC | |
by taint (Chaplain) on Dec 07, 2013 at 03:56 UTC | |
|
Re: All attempts to match data from input fail. Please help. [SOLVED]
by taint (Chaplain) on Dec 07, 2013 at 01:38 UTC | |
by ww (Archbishop) on Dec 07, 2013 at 02:07 UTC | |
by taint (Chaplain) on Dec 07, 2013 at 03:59 UTC |