Re: [exim] Perl Help - easy one

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Dave Evans
Datum:  
To: Exim, Users
Betreff: Re: [exim] Perl Help - easy one
On Fri, Jul 21, 2006 at 07:54:24AM +0100, Peter Bowyer wrote:
> On 21/07/06, Marc Perkel <marc@???> wrote:
> > OK - I'm not a perl programmer - but I'm writing some perl code. I need
> > a quick way to get the host name from an IP address. How do I do this?
>
> http://search.cpan.org/~olaf/Net-DNS-0.58/lib/Net/DNS/Resolver.pm


Or, if you're not so fussed about the details (e.g. if you don't mind not
being able to control the timeout, or being able to detect the difference
between different types of error), then just use the built-in gethostbyaddr():

use Socket qw( inet_aton AF_INET );
my $hostname = gethostbyaddr(inet_aton($ip_address), AF_INET);

Net::DNS is more thorough, but harder work of course.

--
Dave Evans
Power Internet

PGP key: http://powernet.co.uk/~davide/pgpkey