What am I doing wrong here? I'm obviously not understanding what
object is being returned by $packet.

use strict;
use warnings;

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";
}


What I want is a reverse lookup ptr:
 % dig -x 8.8.8.8 | grep PTR
;8.8.8.8.in-addr.arpa.          IN      PTR
8.8.8.8.in-addr.arpa.   40076   IN      PTR     google-public-dns-a.google.com.

So, per the script, the return value should be:
[8.8.8.8] google-public-dns-a.google.com

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to