Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 (Hermit) 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]
NodeReaper wonders through a maze of twisty little sayings, all different

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2018-02-19 18:23 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.