improper return value from net::ping?

B

bubslg

Help! I have a script that does a pingprobe on a list of servers. I
works fine with perl v5.6.1, but does not work with 5.8.8. It looks
like the return value from net::ping has changed. In 5.6.1 I always
get a return of either 1 or 0. In 5.8.8 I get a 1 or 0 with a bunch
of other data including the ip being pinged appended, meaning my
return value is alway going to be non-0. As a result a simple test
like

use Net::ping;
my $p = Net::ping->new("icmp");
print $p->ping("somehost");
$p->close();

is never going to work. Why the change in the return value, and how
do I fix it?
 
G

Gunnar Hjalmarsson

bubslg said:
Help! I have a script that does a pingprobe on a list of servers. I
works fine with perl v5.6.1, but does not work with 5.8.8. It looks
like the return value from net::ping has changed. In 5.6.1 I always
get a return of either 1 or 0. In 5.8.8 I get a 1 or 0 with a bunch
of other data including the ip being pinged appended, meaning my
return value is alway going to be non-0. As a result a simple test
like

use Net::ping;
my $p = Net::ping->new("icmp");
print $p->ping("somehost");
$p->close();

is never going to work. Why the change in the return value, and how
do I fix it?

In the latest version of Net::ping, what the ping() method returns is
context dependent.

perldoc Net::ping

Evaluate ping() in scalar context:

print scalar $p->ping("somehost");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top