This is a sub routine that I copied from CPAN. It works fine as it is when I run it from the command line. I have a similar function from Net::Traceroute that also works fine AND allows me to return the string with a SOAP call. The problem comes when I try to return the ~string(?) from the function below with a SOAP call.
sub tr {
use Net::Traceroute::PurePerl;
my $t = new Net::Traceroute::PurePerl(
backend => 'PurePerl', # this optional
host => 'www.whatever.com',
debug => 0,
max_ttl => 30,
query_timeout => 2,
packetlen => 40,
protocol => 'udp', # Or icmp
);
$t->traceroute;
return $t;
}
The output looks like a string except the last part of the string looks like this:
28 * * *
29 * * *
30 * * *
Net::Traceroute::PurePerl=HASH(0x11fa6bf0)
I don’t know what is different about Net::Traceroute::PurePerl that won’t allow me to return the value with SOAP since the Net::Traceroute version does allow me to return it with SOAP.
Edit:
To debug, I just edited the last lines like this:
#$t->traceroute;
#return $t;
$foo = "test";
return $foo;
Note that this returns “test” throught the SOAP call. However, if I uncomment $t->traceroute;, the SOAP call breaks. The client side gets nothing back through the SOAP call.
Anytime you see something that looks like “HASH(0x11fa6bf0)”, try using Data::Dumper to show you what it is.
(Assuming your hashref is in $t)
use Data::Dumper;
print Dumper $t;
(Data::Printer will give you an even more useful look at what’s inside your reference, particularly if you’ve got coderefs inside it, but the advantage of Data::Dumper is that it’s been in the Perl core for a long time, so you should always have it available…)