This seems like a basic question, but I can't find what I'm looking for.

I'm looking for a module that does DNS name resolution *easy*. I can write the code to do getaddrinfo() / getnameinfo() and the legacy gethostby...() but that's lots of code I cut/paste into my scripts whenever I need name resolution. To make it worse, there are all sorts of checks for Socket version to accommodate for IPv6 - which I need my scripts to be aware of.

I'm looking for something like:

use Magic::Name::Resolution ... host2addr('www.google.com'); # print 1st IP addr returned, 4 or 6 host2ipv4('www.google.com'); # print 1st IPv4 addr returned host2ipv6('www.google.com'); # print 1st IPv6 addr returned ...

Hopefully you get the picture. 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 since my CPAN searches for "DNS", "resolve", "host", "getaddr" turn up the usual suspects which require more "low-level" code writing (which again, I do, but I do repeatedly in all my scripts that need it). Looking for a nice simple API like above in a re-usable module instead of my current cut/paste approach.


In reply to Name resolution module by VinsWorldcom

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.