Hi list,

When Net::DNS resolved name is not found my script dies. How can I allow for my script to continue on even if there is a failed DNS query?

Just cutting and pasting the relevant lines


use Net::DNS;
my $res   = Net::DNS::Resolver->new;

        my $v6_source_hostname = "<<<hostname_removed>>>";
        my $source_ipaddress;
        $source_ipaddress = $res->query("$v6_source_hostname", "AAAA");
        if ($source_ipaddress) {
foreach my $rr (grep { $_->type eq 'AAAA' } $source_ipaddress->answer) {
                print $rr->address, "\n";
            }
        } else {
            warn "query failed: ", $res->errorstring, "\n";
        }




------ output -----

query failed: NXDOMAIN
lookup for <<<hostname_removed>>> failed:
<<script stops here>>>

Cheers

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to