Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: problem with $ARG

by Random_Walk (Parson)
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.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!


Comment on Re: problem with $ARG
Download Code
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
      -E

      (gethostbyname($ARGV[0]))[4])
      is clearer as
      scalar(gethostbyname($ARGV[0]))
      or just
      gethostbyname($ARGV[0])
      if you check if gethostbyname succeeded.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-12-17 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (40 votes), past polls