Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: problem with $ARG

by Random_Walk (Prior)
on Feb 05, 2009 at 10:56 UTC ( #741520=note: print w/ replies, xml ) Need Help??

in reply to problem with $ARG

briefly, risolve is clobbering your $_ which is the default place to which you read the records from the DNS handle. $_ is a global variable so this self same $_ is then used as the key for your hash.

while (my $discard = <DNS>) {1}; # this would fix it

If risolve is intended to resolve the IP address of the hosts you can do this with pure Perl using gethostbyname. This will return a record that you will need to process to get human readable IP address, the linked docco explains how to do this.


Pereant, qui ante nos nostra dixerunt!
Comment on Re: problem with $ARG
Download Code
Replies are listed 'Best First'.
Re^2: problem with $ARG
by tweetiepooh (Friar) on Feb 05, 2009 at 16:01 UTC
    The way to use gethostbyname can be illustrated thusly
    perl -MSocket -M5.010 -e 'say inet_ntoa((gethostbyname("name"))[4]);'

      -M5.010 -e
      can be written as

      is clearer as
      or just
      if you check if gethostbyname succeeded.

      perl -MSocket -E'say inet_ntoa gethostbyname(shift)||die "Not found\n"'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://741520]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2016-05-07 01:40 GMT
Find Nodes?
    Voting Booth?