Subject: | Calling $resolver->nameservers multiple times returns an increasingly-long list |
I think somehow @returnval is being turned into a state variable or something. This is clearer if you use the debugger in a modern Perl (it was clear in perl 5.20.0, totally baffling in 5.14.2).
Test script:
#!/usr/bin/env perl
use Net::DNS;
my $resolver = Net::DNS::Resolver->new(nameservers => ['192.42.93.30']);
for (1..3) {
print "Nameservers are ", join(', ', $resolver->nameservers), "\n";
}
Output:
Nameservers are 192.42.93.30
Nameservers are 192.42.93.30, 192.42.93.30
Nameservers are 192.42.93.30, 192.42.93.30, 192.42.93.30
The offending line appears to be in Net::DNS::Resolver::Base, line 341 in version 0.76:
my @returnval = @{$self->{nameserver6}} if $has_inet6 && !$self->force_v4();
If I replace that with
my @returnval;
@returnval = @{$self->{nameserver6}} if $has_inet6 && !$self->force_v4();
the bug goes away.