botha has asked for the wisdom of the Perl Monks concerning the following question:

I'm resolving ip addresses to host names based upon the following:
#!/usr/bin/perl -w use strict; use Socket; foreach my $ip (@ARGV) { my $sin = inet_aton($ip); my $name = gethostbyaddr $sin, AF_INET; print "$ip => $name\n"; }
This works but I would like to change the server it uses to resolve the ip from within the code. My research has proved futile.

Replies are listed 'Best First'.
Re: How do I change servers while using gethostbyaddr
by fokat (Deacon) on Dec 15, 2001 at 03:59 UTC
    gethostbyaddr() uses your machine's name resolution mechanisms. In general, you cannot (easily) do what you want. I suggest you go and fetch Net::DNS from the nearest CPAN archive. With this module, you can emulate your DNS resolver behavior in quite powerful ways. In particular, you can specify a list of name servers to query, and craft customized DNS questions. Good luck...