You might also check out http://www.fuhr.net/users/mfuhr/perldns/ (which I
found via http://www.acmebw.com/askmrdns/00246.htm)
I don't know Perl (shame on me) but the naptr.pm module is only 112 lines
(not counting the appended man page) so with a little work you ought to be
able to glean something useful from it even if you (also) don't know Perl.
Best wishes,
- Joe