The program
#!/usr/add-on/ncmp/bin/perl5 -w
use Net::Ping;
warn "pinging";
if (pingecho('deadmach', 2))
{
warn "passed!";
}
else
{
warn "failed";
}
produces
pinging at /usr/tmp/pingtest line 5.
Argument "" isn't numeric for numeric eq at
/usr/add-on/ncmp/lib/perl5.001/lib/perl5/Net/Ping.pm line 100.
failed at /usr/tmp/pingtest line 13.
I fixed it once by changing
$ret == 1 ? 1 : 0
to
$ret eq 1 ? 1 : 0
but that didn't feel like the right answer. So I changed
alarm(0);
close(PINGSOCK);
$ret == 1 ? 1 : 0 ;
to
$ret = 0 if defined($@);
alarm(0);
close(PINGSOCK);
$ret == 1 ? 1 : 0 ;
I wasn't sure, after reading eval on perlfunc, if the eval should
return undef or a mysterious undefined value in this case. If the
latter, I suggest you add something like '(not undef!)' after the
word 'undefined' in that section.
--
Robert W. Gebhardt
AT&T Global Business Communications Systems
11900 N. Pecos St.
Denver, CO 80234
gebha@dr.att.com
Phone: 303-538-4726
FAX: 303-538-3564
#!/usr/add-on/ncmp/bin/perl5 -w
use Net::Ping;
warn "pinging";
if (pingecho('deadmach', 2))
{
warn "passed!";
}
else
{
warn "failed";
}
produces
pinging at /usr/tmp/pingtest line 5.
Argument "" isn't numeric for numeric eq at
/usr/add-on/ncmp/lib/perl5.001/lib/perl5/Net/Ping.pm line 100.
failed at /usr/tmp/pingtest line 13.
I fixed it once by changing
$ret == 1 ? 1 : 0
to
$ret eq 1 ? 1 : 0
but that didn't feel like the right answer. So I changed
alarm(0);
close(PINGSOCK);
$ret == 1 ? 1 : 0 ;
to
$ret = 0 if defined($@);
alarm(0);
close(PINGSOCK);
$ret == 1 ? 1 : 0 ;
I wasn't sure, after reading eval on perlfunc, if the eval should
return undef or a mysterious undefined value in this case. If the
latter, I suggest you add something like '(not undef!)' after the
word 'undefined' in that section.
--
Robert W. Gebhardt
AT&T Global Business Communications Systems
11900 N. Pecos St.
Denver, CO 80234
gebha@dr.att.com
Phone: 303-538-4726
FAX: 303-538-3564