Forum Moderators: coopster & phranque

Message Too Old, No Replies

gethostbyaddr in perl?

         

Richie0x

1:59 pm on May 21, 2004 (gmt 0)

10+ Year Member



In php you can resolve an IP address to the hostname using gethostbyaddr() but how do you do it in Perl?

VectorJ

2:46 pm on May 21, 2004 (gmt 0)

10+ Year Member



Not quite as streamlined as PHP, but still not too bad:


use Socket;
my $ipaddr = inet_aton("****.xxx.xxx.xxx");
my $host = gethostbyaddr($ipaddr, AF_INET);

where xxx.xxx.xxx.xxx is the ip address you're looking up.