Jay Levitt wrote: [SNIP]
I tried to create a test harness to see if I can replicate this outside of SA, but for some reason, even though I double-checked the code I copied from Dns.pm, I'm getting weird results - it's always giving me the root nameservers, instead of the name servers for each of the domains. This is true with recurse => 0, recurse => 1, or recurse left out entirely as it is in Dns.pm. I'm no Perl whiz; can anyone see my mistake?
Code follows:
-------------
#!/usr/bin/perl
no strict; no warnings;
require Net::DNS; require Net::DNS::Resolver;
use strict; use warnings;
my @EXISTING_DOMAINS = qw{ adelphia.net akamai.com apache.org cingular.com colorado.edu comcast.net doubleclick.com ebay.com gmx.net google.com intel.com kernel.org linux.org mit.edu motorola.com msn.com sourceforge.net sun.com w3.org yahoo.com };
my $res = Net::DNS::Resolver->new ( recurse => 0, retry => 1, retrans => 0, dnsrch => 0, defnames => 0, tcp_timeout => 3, udp_timeout => 3, persistent_tcp => 1, persistent_udp => 1 );
die unless defined $res;
for(;;) { my @domains = @EXISTING_DOMAINS; my $domain = splice(@domains, rand(@domains), 1); print "trying '$domain'...\n"; lookup_ns($domain); }
sub lookup_ns { my ($self, $dom) = @_;
^^^^ Since you're not using this as a Perl Module (OOP) my guess is that $self contains the value you expect to be in $dom and $dom is NULL.
Try removing $self from your argument list and make it look like: my ($dom) = @_;
and see if that works for you.
debug statements are your friend. :)
hope this helps
alan