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:
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.