Perl while 死循环

use warnings;    
use Net::Ping;  
 $J=0;
 $K=0;
$ret=0;

$duration=0;
for ($i = 1;$i <= 1000;$i++){  
if ($#ARGV <0){    
   print "请输入一个参数\n";    
  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)\n", 1000 * $duration)
      if $ret;
    $p->close();
}

print "$host active is $J\n";

print "$host lost is $K\n";


##($host, 2); 后面那个是超时时间


 
 

你可能感兴趣的:(Perl高级编程)