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

Kent Johnson kent37 at tds.net
Sat Jan 31 14:44:58 CET 2009


On Sat, Jan 31, 2009 at 7:11 AM,  <hongyi.zhao at gmail.com> wrote:
> Hi all,
>
> The script in the following can do the batch conversion from domain name to IP:

?? This is a Python list, not Perl!

Kent
>
> ------------------
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Socket;
>
> while ( <> ) {
>     chomp;
>     my ( $address, $port ) = split /:/ or next;
>     my $number = inet_aton $address;
>     my $ip     = inet_ntoa $number;
>     print "$address:$port -> $ip:$port\n";
>     }
>
> __END__
>
> ------------------
>
>
> 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.
>
> Regards,
> --
> Hongyi Zhao <hongyi.zhao at gmail.com>
> Xinjiang Technical Institute of Physics and Chemistry
> Chinese Academy of Sciences
> GnuPG DSA: 0xD108493
> 2009-1-31
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list