On Thu, Mar 7, 2013 at 11:40 AM, Lawrence Statton <lawre...@cluon.com> wrote: > On 03/07/2013 10:21 AM, shawn wilson wrote: >> >> use Data::Dumper; >> use Net::DNS::Resolver; >> >> my $dns = Net::DNS::Resolver->new; >> >> print rev_ip('8.8.8.8') . "\n"; >> >> sub rev_ip >> { >> my ($ip) = @_; >> >> my $packet = $dns->search($ip); >> my @authority = $packet->authority; >> my $string = join ', ', map { $_->name } @authority; >> return "[$ip] $string"; >> } >> > > Your results may vary, but for the vast majority of resolvers out there, you > are not going to get any authority records - because most of them are not > authoritative. > > You probably want to be looking in the ANSWER. > > Also - since you gave it the name - you already knew that part - it's what > you gave the resolver. What you want is the rdatastr method (perldoc > Net::DNS::RR) > > > sub rev_ip > { > my $string = join ', ', map { $_->rdatastr } $dns->search($_[0])->answer; > return "[$_[0]] $string"; > }
Yeah, I'm looking at the Net::DNS::RR doc... And I got it to work in the test script doing this: my $packet = $dns->search($ip); my @authority = $packet->pre; my $string = join ', ', map { $_->rdata } @authority; However, when I @EXPORT this function from a module, I get this: Can't call method "pre" on an undefined value at lib/Misc.pm line 45, <> line 723793. I've tried newing up Net::DNS::Resolver inside the sub with the same result. I've also tried closuring $dns in the sub with the same result. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/