Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: problem with $ARG

by Random_Walk (Prior)
on Feb 05, 2009 at 10:56 UTC ( [id://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!

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
      -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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://741520]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-19 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found