Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Dns lookups

by perlaintdead (Scribe)
on Dec 12, 2013 at 00:47 UTC ( #1066753=note: print w/ replies, xml ) Need Help??


in reply to Re: Dns lookups
in thread Dns lookups

you can also get rid of that pesky array

use Socket;print "$_\n".inet_ntoa((gethostbyname$_)[4])."\n\n" for @AR +GV;


Comment on Re^2: Dns lookups
Download Code
Re^3: Dns lookups
by hippo (Curate) on Dec 12, 2013 at 09:44 UTC

    The array is there to cope with the possibility of an unresolvable host. If you try your example above with args like

    ./pllookup.pl dklghslfhslgshj.com foo.com

    the unresolvability of dklghslfhslgshj.com would cause it to die on the first argument, whereas with the array it will just skip that and carry on to the remaining args. To my mind that's a better UX but others may disagree.

      The golfer in me couldn't resist

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066753]
help
Chatterbox?
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: (12)
As of 2014-08-27 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (244 votes), past polls