Thanks for trying it out. You were right about the eval - it was part of a callback routine called from Tk::Timer. I don't know why it wasn't crashing the whole program, but I swear I had strict and diagnostics on.

I eventually got it working with Net::DNS, and managed to reproduce the error there too. But because the query is broken into parts I was able to get a bit closer to the problem. If you do a reverse lookup (effectively an ordinary lookup on the reverse zone) and there's no record, you actually get a DNS reply packet with no records in it rather than a fail. But it appears the writers of the code did not envisage a DNS lookup that was partially successful (returns a packet with no RRs, rather than failing outright), since if you can get through to the primary DNS for a zone you can always get either a address RR or a not found (for a host->address lookup). But the reverse zone DNS seems to return a 'found' (since we know the machine exists) with no RRs (since the machine doesn't have a hostname that the DNS knows about). The code doesn't seem do any sanity checking, tries to load an RR (which isn't there) and then falls over.

Phew!

The short of that is that reverse DNS lookups on broken domains can break the support libraries. The only real way to be sure is to use Net::DNS and check that you actually have a RR before you try and print it out.

* A RR is a resource record, or a mapping from hostname to ip address or vice versa. They have to be manually entered in the DNS but some DNS admins get lazy/clever and don't enter the ip address to hostname listing.

____________________
Jeremy
I didn't believe in evil until I dated it.


In reply to Re: Re: gethost from Net::Hostent fails strangely by jepri
in thread gethost from Net::Hostent fails strangely by jepri

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.