G
Gregory Toomey
I'm a bit confused about the Perl OO syntax. From my reading "foreach" acts
as an iterator.
Any somebody tell me in the standard example below:
- how to count the total number of $query->answer
- how to access the i'th answer; $query->answer[$i] does not work
- how to access a random answer
thanks
gtoomey
--
use Net:
NS;
my $res = Net:
NS::Resolver->new;
my $query = $res->query("example.com", "NS");
if ($query) {
foreach $rr (grep { $_->type eq 'NS' } $query->answer) {
print $rr->nsdname, "\n";
}
}
as an iterator.
Any somebody tell me in the standard example below:
- how to count the total number of $query->answer
- how to access the i'th answer; $query->answer[$i] does not work
- how to access a random answer
thanks
gtoomey
--
use Net:
my $res = Net:
my $query = $res->query("example.com", "NS");
if ($query) {
foreach $rr (grep { $_->type eq 'NS' } $query->answer) {
print $rr->nsdname, "\n";
}
}