Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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!

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 about the Monastery: (3)
As of 2016-10-24 03:05 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.