mmm, okay.
Well, just for the sake of the exercise, I re-wrote your script and simplified it a bit. I also changed it so that it would take a domain name to test from the command line. Here is my version:
#!/usr/bin/perl -w use strict; use Net::DNS; my $domain = shift or die "Please supply a domain to query\n"; my @ips = resolve($domain); my $i; for (@ips) { print ++$i . ": $_\n"; } sub resolve { my $domain = shift; my $res = Net::DNS::Resolver->new; my $query = $res->search($domain); my @results; if ($query) { foreach my $rr ($query->answer) { next if $rr->type ne "A"; push @results, $rr->address . " (record type " . $rr->type + . ")"; } return @results; } else { return $res->errorstring; } }

I get similar results with this as I did with your original, but perhaps you can try this and see if it makes any difference. Some sample output:

time perl resolver.pl cnn.com 1: 64.236.24.12 (record type A) 2: 64.236.24.20 (record type A) 3: 64.236.24.28 (record type A) 4: 64.236.29.120 (record type A) 5: 64.236.16.20 (record type A) 6: 64.236.16.52 (record type A) 7: 64.236.16.84 (record type A) 8: 64.236.16.116 (record type A) real 0m0.562s user 0m0.320s sys 0m0.010s

As you can see, still quite fast. I also tried it on a windoze box and it returns just as quickly.

Hope this helps somewhat,
Darren :)


In reply to Re^3: Net::DNS::Resolver and very slow reply by McDarren
in thread Net::DNS::Resolver and very slow reply by mellin

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.