c has asked for the wisdom of the Perl Monks concerning the following question:

Okay, I give. I am brand new to perl and the only modules that I have used are File::Copy and Getopt::Std, so my experience is limited. I am trying to get into using Net::DNS and not having a very fun time. I am working on just trying to get a fqdn to resolve to an ip address. I have read the Net::DNS documentation. I also read the docs for Net::DNS::RR and Net::DNS::RR::PTR but I am just missing the construction. So far, I have:
#!/usr/bin/perl -w #use strict; use Net::DNS; $res = new Net:DNS::RR; $query = $res->query("216.8.86.8","PTR"); if ($query) { foreach $rr ($query->answer) { next unless $rr->type eq "PTR"; print "ptrdname =", $rr->ptrdname, "\n"; # print $rr->address, "\n"; } } else { print "query failed: ", $res->errorstring, "\n"; }

however, I just dont think this is correct syntax. I may be confusing some syntax that is proper for other Net::DNS modules and not RR::PTR.
A point in the right direction will help. Please dont refer me to the perldoc on these modules as the info contained there is the same as on cpan. humbly -c

Edit kudra, 2001-07-20 Changed title

Replies are listed 'Best First'.
Re: a href= (Net::DNS question)
by Graham (Deacon) on Jul 20, 2001 at 12:16 UTC
    change your definition of $res from
    $res = new Net::DNS::RR;
    to become
    $res = new Net::DNS::Resolver;
    As far as I can see, the rest looks ok, I can see 216.8.86.8 as ns1.lunarmedia.net using your script with that modification
      Thats interesting that you say you get good results from the script after you make your change. When I make the same change in my script locally, I receive:
      defined(@array) is deprecated at /usr/lib/perl5/site_perl/5.6.0/Net/DN +S.pm line 137. (Maybe you should just omit the defined()?) syntax error at ./ipnew line 6, near "new Net:" Execution of ./ipnew aborted due to compilation errors.
      I have Net-DNS-0.12 installed and running

      This is perl, v5.6.0 built for i386-linux

      The part about the syntax error near new Net is just out of my grasp. Am I missing something obvious?

      humbly -c

        Your original code only has one colon in that statement which is why you are getting the error.
        Change
        $res = new Net:DNS::Resolver;
        so that it reads
        $res = new Net::DNS::Resolver;