Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: problem with $ARG

by tweetiepooh (Hermit)
on Feb 05, 2009 at 16:01 UTC ( [id://741585]=note: print w/replies, xml ) Need Help??


in reply to Re: problem with $ARG
in thread problem with $ARG

The way to use gethostbyname can be illustrated thusly
perl -MSocket -M5.010 -e 'say inet_ntoa((gethostbyname("name"))[4]);'

Replies are listed 'Best First'.
Re^3: problem with $ARG
by ikegami (Patriarch) on Feb 05, 2009 at 16:11 UTC

    -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://741585]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found