Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Name resolution module

by hippo (Bishop)
on Oct 03, 2017 at 12:17 UTC ( [id://1200605]=note: print w/replies, xml ) Need Help??


in reply to Name resolution module

All the messy stuff I do in code to resolve those names to addresses is obscured in a module. I thought of putting all my code in a module, but wanted to see what you all use

TBH, with Net::DNS it is relatively simple so I've never bothered to code up a wrapper:

#!/usr/bin/env perl use strict; use warnings; use Net::DNS; my $res = Net::DNS::Resolver->new (); print "Any: " . $res->query('www.google.com')->pop('answer')->rdstrin +g . "\n"; print "IPv4: " . $res->query('www.google.com', 'A')->pop('answer')->rd +string . "\n"; print "IPv6: " . $res->query('www.google.com', 'AAAA')->pop('answer')- +>rdstring . "\n";

The advantage is that if you are interested in any other aspects of the responses or the resolver those are easily obtainable/settable.

Replies are listed 'Best First'.
Re^2: Name resolution module
by VinsWorldcom (Prior) on Oct 03, 2017 at 13:52 UTC

    Now that's interesting!! ++ I hadn't seen Net::DNS used that way. That could be what I'm looking for - thanks for the helpful usage; I'll have a deeper look.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1200605]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found