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:
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.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"; } }
In reply to Re: Re: perl to convert text list of ip address to a name
by biosysadmin
in thread perl to convert text list of ip address to a name
by lola_marais
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |