I have the following global:
my $ip_address = shift;
use strict;
use Net::DNS;
use IO::Select;
my $timeout = 5;
my $nameserver = "ns.phys.uu.nl";
my %host;
my $result;
my $res = new Net::DNS::Resolver;
$res->nameservers( $nameserver );
my $bgsock = $res->bgsend( $ip_address );
my $sel = new IO::Select($bgsock);
my @ready = $sel->can_read($timeout);
if (@ready) {
foreach my $sock (@ready) {
if ($sock == $bgsock) {
my $packet = $res->bgread($bgsock);
if ($packet) {
foreach my $rr ($packet->answer) {
my $hostname = $rr->rdatastr;
$hostname =~ s/\.$//g;
$result = $hostname;
}
}
else {
$result = $ip_address;
}
$bgsock = undef;
}
$sel->remove($sock);
$sock = undef;
}
}
else {
$result = $ip_address;
}
if ( $result eq "" ) { $result = $ip_address; }
return $result;
}
When I use <%hostlookup($online_ip)%>, I get Error: Variable 'hostlookup' is not a code reference
Any ideas what might cause this? The thing is, the code used to work in GForum v 1.0.0, but it doesn't in 1.1.1. I already tried to change the last line into "return \$result;" but that wouldn't work.
Ivan
-----
Iyengar Yoga Resources / GT Plugins
Code:
sub { my $ip_address = shift;
use strict;
use Net::DNS;
use IO::Select;
my $timeout = 5;
my $nameserver = "ns.phys.uu.nl";
my %host;
my $result;
my $res = new Net::DNS::Resolver;
$res->nameservers( $nameserver );
my $bgsock = $res->bgsend( $ip_address );
my $sel = new IO::Select($bgsock);
my @ready = $sel->can_read($timeout);
if (@ready) {
foreach my $sock (@ready) {
if ($sock == $bgsock) {
my $packet = $res->bgread($bgsock);
if ($packet) {
foreach my $rr ($packet->answer) {
my $hostname = $rr->rdatastr;
$hostname =~ s/\.$//g;
$result = $hostname;
}
}
else {
$result = $ip_address;
}
$bgsock = undef;
}
$sel->remove($sock);
$sock = undef;
}
}
else {
$result = $ip_address;
}
if ( $result eq "" ) { $result = $ip_address; }
return $result;
}
When I use <%hostlookup($online_ip)%>, I get Error: Variable 'hostlookup' is not a code reference
Any ideas what might cause this? The thing is, the code used to work in GForum v 1.0.0, but it doesn't in 1.1.1. I already tried to change the last line into "return \$result;" but that wouldn't work.
Ivan
-----
Iyengar Yoga Resources / GT Plugins