All,
Can someone explain this code line by line?
Obviously I understand most of it but lines 4, 5, 6 and 10 I am fuzzy.
For line 4: if ($query) ..... if what? Here I would expect to see if ( -s
$query ) or something like a return code/exit code value check like $? >>
8.
What is if ($query) saying? Is there a more beginner way? After line 3
could I check the exit value then run a more obvious if statement?
For line 5: foreach my $rr, we are looking for a record string eq to
NS(nameserver) from $query answer? But where does $rr, $_ and answer come
from?
This entire line is fuzzy to me. Is there a more beginner way ? I would
probably write it like:
foreach ($query->answer) {
if ( $_ eq NS) {
print $rr->nsdname, "\n";
}
}
For line 10: $res->errorstring. Where does errorstring come from? Are
there globals in this module that I am missing? I looked on CPAN and did
not find any.
In general I am having trouble understanding and using this modules
potential.
1> use Net::DNS;
2>my $res = Net::DNS::Resolver->new;
3> my $query = $res->query("example.com", "NS");
4>if ($query) {
5>foreach my $rr (grep { $_->type eq 'NS' } $query->answer) {
6> print $rr->nsdname, "\n";
7> }
8>}
9>else {
10> warn "query failed: ", $res->errorstring, "\n";
11> }
thank you,
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>