in reply to Help With Net::Whois::IP

Let's look at your code line-by-line...
use strict; # good use warnings; # good use Net::Whois::IP qw(whoisip_query); # I can't test as I don't have the Net::Whois::IP # module installed use Data::Dumper; # Here is a module you invoke but from which you don't # call anything, at least in this example. &whois(); # why do you call this with no params # and use lexicals form the $main:: # package within it? This is not # directly related to your problem, but # is bad form. You also call it in void # context even though you make it return # values... my ($ip, $email, $techname); # The above call returns things that are not # declared until here. Think about what my() will # do to these variables at this point in the program. print "$ip\'s name is $techname and email address is $email\n"; # There's a concatenation done here. Is this # the line that complains? Why would these variables # not be initialized? sub whois{ $ip = '149.1.1.1'; my ($response,$array_of_responses) = whoisip_query($ip); $email = $response->{TechEmail}; $techname = $response->{TechName}; return ($email, $techname); # Here you return something # which your main program # is throwing away because # the sub is called in # void context. ####!!! There should be a closing curly for this sub!!!
I can't test anything right now because I don't have the time to install Net::Whois::IP for just a test. However, let's see if you get the same error with the following code. Even if you do, it may be easier to track down.
use strict; use warnings; use Net::Whois::IP qw(whoisip_query); use Data::Dumper; my ($ip, $email, $techname); $ip = '149.1.1.1'; ( $email, $techname ) = whois($ip); print "$ip\'s name is $techname and email address is $email\n"; sub whois { my $addr = shift; my ($response,$trash) = whoisip_query($addr); $email = $response->{TechEmail}; $techname = $response->{TechName}; return ($email, $techname); }


Christopher E. Stith

Replies are listed 'Best First'.
Re: Re: Help With Net::Whois::IP
by Dru (Hermit) on Jul 02, 2003 at 18:48 UTC
    Thanks for taking the time to reply. My messy code was a result of some testing thus the strange scoping. I used your code and the one from the first problem and I'm having the same problem.
      I would try printlining the variables which are used in that line to see the values. This may be something specific to the module you are using not doing what you expect.

      Christopher E. Stith