When iam using this code
use Net::DNS::Resolver;
my $res = Net::DNS::Resolver->new();
my $packet = $res->search('www.indiaimage.nic.in', 'HINFO');
my ($rr) = $packet->answer();
print "cpu = ", $rr->cpu, " os = ", $rr->os, "\n";
Iam getting error:
Can't call method "answer" on an undefined value at hinfo.pl line 4.
My requiement is that If i give any hostname i have to get
remote O.S. used by that host.
You will need to check the Net::DNS documentation to find out what happens when the query fails or is not found. My guess is that the record is not found. You will need to check for this.
This is not surprising since HINFO records are rare. Unless you know that that domain defines them, doing the query is not going to useful.