Edit: I'm smoking crack. Sorry saskaqueer. Old thread is shown below ...
I think you have it backwards, the original poster asked for a way to convert IP addresses to hostnames, not hostnames to IP addresses.
Here's some example code using Net::DNS:
use Net::DNS;
my @domains = qw/google.com perl.com perlmonks.org cpan.org/;
my $res = Net::DNS::Resolver->new;
foreach my $domain( @domains ) {
my $query = $res->search($domain);
if ($query) {
foreach my $rr ($query->answer) {
next unless $rr->type eq "A";
print $rr->address, "\n";
}
} else {
warn "query failed: ", $res->errorstring, "\n";
}
}
Be forewarned: Net::DNS is a bit slow, but it does get the job done. Printing a CSV list of the domains and their associated IP addresses is an exercise left to the reader.