<pre name="code" class="sql">use warnings;
use Net::Ping;
$J=0;
$K=0;
$ret=0;
$duration=0;
for ($i = 1;$i <= 1000;$i++){
if ($#ARGV <0){
print "请输入一个参数
";
exit(-1);
}
$host = $ARGV[0];
$p = Net::Ping->new();
$p->hires();
($ret, $duration, $ip) = $p->ping($host);
printf("$host [ip: $ip] is alive (packet return time: %.2f ms)
", 1000 * $duration)
if $ret;
$p->close();
}
print "$host active is $J
";
print "$host lost is $K
";
##($host, 2); 后面那个是超时时间