use warnings;
use Net::Ping;
if ($#ARGV <0){
print "请输入一个参数
";
exit(-1);
}
$var=$ARGV[0];
@ARRAY="";
for ($i = 1;$i<=255;$i++){
push @ARRAY, "$var.$i"};
foreach $host (@ARRAY){
$p = Net::Ping->new("icmp");
# print "$host is alive.
" if $p->ping($host,5);
print "$host is ";
print "lost " unless $p->ping($host, 2);
print "reachable.
";
$p->close();
#sleep(1);
}