Greetings, Monks.

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

#!/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";}
Yea, I know. Pretty much worthless. But even complete examples were worthless -- they didn't work. :(

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.

In reply to All attempts to match data from input fail. Please help. by taint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.