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