Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You say "a single text field" but your examples refer to two different fields: address and ip, so I am unsure what you want to do.

If you have text fields address and ip, perhaps you could do something like:

use strict; use warnings; use CGI; use Net::Whois::Raw; use Net::Whois::ARIN; my $q = new CGI; my $domname = $q->param("domname"); my $ip = $q->param('ip'); print "content-type:text/plain; charset=utf-8\n\n"; if (!$domname) { print ""; } else { my $text = get_whois($domname, undef, "QRY_LAST"); print $text; } my $w = Net::Whois::ARIN->new( host => 'whois.arin.net', port => 43, timeout => 30, ); if (!$ip) { print ""; } else { my @records = $w->network($ip); foreach my $net (@records) { # print ...; } }

But, if you have a single text field (I have guessed the single field is named 'server'), maybe something like this:

use strict; use warnings; use CGI; use Net::Whois::Raw; use Net::Whois::ARIN; my $w = Net::Whois::ARIN->new( host => 'whois.arin.net', port => 43, timeout => 30, ); my $q = new CGI; my $server = $q->param("server"); print "content-type:text/plain; charset=utf-8\n\n"; if($server and $server ne "") { print "get_whois says:\n"; print get_whois($server, undef, "QRY_LAST"); print "\n\n"; print "ARIN says:\n"; my $output = $w->query("n + $server"); print "$output\n"; } else { print "No server\n"; }

You could check the server parameter to see if it looks like a domain name or a network address then call one function or the other accordingly, or call both functions and report both results, or check the results and only report "successful" results, for whatever you consider a successful lookup.


In reply to Re: How to deal with multiple functions served from only one input field? by ig
in thread How to deal with multiple functions served from only one input field? by taint

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (9)
As of 2024-03-28 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found