swissknife has asked for the wisdom of the Perl Monks concerning the following question:
Dear Experts
i am trying to get the IP address returned by the API getaddrinfo(). i have no experience with Socket module but i found some code online and giving a try. i use the following code.
#!/usr/bin/perl use Socket; my $server = shift @ARGV; my $pip = gethostbyname($server); my $IP_add = inet_ntoa($pip); print $IP_add;
this returns the IP address of the server passed as argument.
but when i try to print the value of $pip, it returns nothing and if i try to pass the $server directly instead of $pip it gives me error. i am not able to understand when $pip has nothing in it, it works but if i pass $server which has name of server in it it gives error.
could someone explain?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl and getaddrinfo API
by Athanasius (Archbishop) on Apr 20, 2016 at 11:23 UTC | |
by swissknife (Sexton) on Apr 20, 2016 at 12:28 UTC | |
by Athanasius (Archbishop) on Apr 20, 2016 at 12:47 UTC | |
by VinsWorldcom (Prior) on Apr 20, 2016 at 17:29 UTC | |
|
Re: perl and getaddrinfo API
by trippledubs (Deacon) on Apr 20, 2016 at 12:53 UTC |