niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Apps » Exim
Perl Help - easy one
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Marc Perkel
*nix forums Guru


Joined: 27 Jan 2005
Posts: 502

PostPosted: Fri Jul 21, 2006 5:54 am    Post subject: Perl Help - easy one Reply with quote

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?


--
## List details at http://www.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://www.exim.org/eximwiki/
Back to top
Peter Bowyer
*nix forums Guru


Joined: 27 Jan 2005
Posts: 340

PostPosted: Fri Jul 21, 2006 6:54 am    Post subject: Re: Perl Help - easy one Reply with quote

On 21/07/06, Marc Perkel <marc@perkel.com> wrote:
Quote:
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?

search.cpan.org is your friend.

http://search.cpan.org/~olaf/Net-DNS-0.58/lib/Net/DNS/Resolver.pm

Don't forget to handle errors, timeouts, 'No Data', CNAMEs (which are
common in the in-addr.arpa zone to handle classless delegation), and
the fact that there may be more than one host name and the order the
multiple ones arrive in isn't necessarily consistent,

Peter

--
Peter Bowyer
Email: peter@bowyer.org

--
## List details at http://www.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://www.exim.org/eximwiki/
Back to top
Dave Evans
*nix forums beginner


Joined: 20 Mar 2006
Posts: 39

PostPosted: Fri Jul 21, 2006 7:19 am    Post subject: Re: Perl Help - easy one Reply with quote

On Fri, Jul 21, 2006 at 07:54:24AM +0100, Peter Bowyer wrote:
Quote:
On 21/07/06, Marc Perkel <marc@perkel.com> 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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Sun Nov 23, 2008 1:40 pm | All times are GMT
navigation Forum index » Apps » Exim
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Need Help with Program in Perl on a Netware Server fhadzocos@gmail.com Perl 3 Fri Jul 21, 2006 1:57 pm
No new posts problems using oddmuse with mod_perl2 inside apache2.2 pe... Fergus McMenemie Perl 0 Fri Jul 21, 2006 9:48 am
No new posts Problem with Win32-SerialPort over bluetooth @ windows + ... ctloh Perl 0 Fri Jul 21, 2006 8:08 am
No new posts Posting Guidelines for comp.lang.perl.misc (: 1.... Tad McClellan Perl 0 Fri Jul 21, 2006 7:22 am
No new posts how to get perl to untar a tar.gz to a different directory Jack Perl 2 Fri Jul 21, 2006 12:40 am

Personal Car Finance | Bikini Model | Personal Loans | Debt Consolidation | Car Credit
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.5096s ][ Queries: 16 (0.2532s) ][ GZIP on - Debug on ]