in reply to perl to convert text list of ip address to a name
use Socket; # For Binary-> IP dot quad etc... use Net::Whois::IANA; # For IP -> Name # Get IP addr # Call the sub below, and print value sub Get_Whois_Name { my $ip = shift; my $Save_ = $_; # The WhoIs module messes with $_ (BUG!!) # Save current value for restore upon exit. ##print "LOOKING FOR $ip ===="; my $iana = new Net::Whois::IANA; $iana->whois_query(-ip=>$ip); my $name = $iana->descr(); if ($name =~m/not allocated/){ $name = "Country=" .$iana->country() ."+Net=" . $iana->netname(); } #Zap commas in name $name =~s/\,/ /g; $_ = $Save_; # Restore return $name; } ##########################################
By guaranteeing freedom of expression, the First Amendment also guarntees offense.
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: perl to convert text list of ip address to a name
by tilly (Archbishop) on May 17, 2004 at 23:50 UTC | |
by Anonymous Monk on May 17, 2004 at 23:57 UTC | |
by tilly (Archbishop) on May 18, 2004 at 00:31 UTC |