Resolving hostnames with Perl

I recently added name resolution support to This was super easy to do, and only required three lines of Perl code:

### Import the required modules
use Socket;

### Convert the IP address string to an Internet address
my $ipaddr = inet_aton($index);

### Resolve the IP address to a hostname
my $host = gethostbyaddr($ipaddr, AF_INET);

Once the conversion and resolution complete, the name will be available in the $host scalar variable. Giddie up!

Leave a Reply

Your email address will not be published. Required fields are marked *