Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Net::DNS::Resolver::Recurse issue

by gtech99 (Initiate)
on Jul 14, 2024 at 12:36 UTC ( [id://11160598]=note: print w/replies, xml ) Need Help??


in reply to Re: Net::DNS::Resolver::Recurse issue
in thread Net::DNS::Resolver::Recurse issue

Oops, sorry. Really basic stuff. This fails on domains that have listed two nameservers, but only one provides actual answers because the other one is offline or misconfigured.
#!/usr/local/bin/perl use Net::DNS::Resolver::Recurse; my $res = Net::DNS::Resolver::Recurse->new; my $coderef = sub { my $packet = shift; printf ";; Received %d bytes from %s\n\n", $packet->answersize, $packet->answerfrom; }; $res->callback($coderef); $res->debug(0); my $reply = $res->query("test.com", "MX"); if ($reply) { foreach $rr (grep { $_->type eq "MX" } $reply->answer) { print $rr->exchange, $rr->preference, "\n"; } } else { warn "query failed: ", $res->errorstring, "\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-09-07 14:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.