As I have proclaimed previously, I'm a great proponent of implementation within Perl as opposed to the calling of external programs and I would direct your attention to the Net::DNS module.
in reply to dnsquery and Linux
This module is exceptionally easy to use and the module documentation includes a number of example pieces of code which can easily be tailored to your needs, including host address resolution, nameserver resolution, MX record resolution, zone transfers and SOA retrieval.
Update: Also too, after a little Google-whoring, I found DNSwalk which makes extensive use of Net::DNS to debug DNS databases by walking through zone files and confirming zone data.
Ooohhh, Rob no beer function well without!