Can someone help me to convert the following perl code into php? Leave the Net::DNS, Net::DNS::Resol ver, search functions as is. I can replace them with PEAR Net_DNS module.
[code=perl]
use Net::DNS;
sub ablookup {
my ($domain) = @_;
my ($res, $query, @r);
$res = new Net::DNS::Resol ver;
while(1) {
$query = $res->search("$domai n.contacts.abus e.net", "TXT");
if ($query) {
my $rr;
foreach $rr ($query->answer) {
push @r, $rr->txtdata if $rr->type eq "TXT";
}
return @r;
} else { # Net::DNS rejects special characters, strip off
# subdomains and see if a parent domain works
if($domain =~ m{^[^.]+\.([^.]+\..+)}) {
$domain = $1;
} else {
die "Cannot lookup contacts for $domain";
}
}
}
}
[/code]
Thanks,
[code=perl]
use Net::DNS;
sub ablookup {
my ($domain) = @_;
my ($res, $query, @r);
$res = new Net::DNS::Resol ver;
while(1) {
$query = $res->search("$domai n.contacts.abus e.net", "TXT");
if ($query) {
my $rr;
foreach $rr ($query->answer) {
push @r, $rr->txtdata if $rr->type eq "TXT";
}
return @r;
} else { # Net::DNS rejects special characters, strip off
# subdomains and see if a parent domain works
if($domain =~ m{^[^.]+\.([^.]+\..+)}) {
$domain = $1;
} else {
die "Cannot lookup contacts for $domain";
}
}
}
}
[/code]
Thanks,
Comment