[Tutor] Want to write a Perl based IP to Domain Name converter.

hongyi.zhao at gmail.com hongyi.zhao at gmail.com
Sat Jan 31 13:11:41 CET 2009

Hi all,

The script in the following can do the batch conversion from domain name to IP:


use warnings;
use strict;
use Socket;

while ( <> ) {
     my ( $address, $port ) = split /:/ or next;
     my $number = inet_aton $address;
     my $ip     = inet_ntoa $number;
     print "$address:$port -> $ip:$port\n";



If I want to do the opposite thing, i.e., conversion from IP to domain
name, what should I revise this script to do the trick.

Hongyi Zhao <hongyi.zhao at gmail.com> 
Xinjiang Technical Institute of Physics and Chemistry
Chinese Academy of Sciences 
GnuPG DSA: 0xD108493

More information about the Tutor mailing list