use HTTP::Date qw(time2iso str2time time2iso time2isoz);
use Net::Ping;
use Socket;
my @array=( "api.weixin.qq.cz"
);
while (1==1){
my $CurrTime = time2iso(time());
foreach $host (@array){
$p = Net::Ping->new("icmp" );
$ip_addr=gethostbyname($host);
eval {$packed_ip_addr= inet_ntoa($ip_addr)};
# $packed_ip_addr= inet_ntoa($ip_addr);
if ($p->ping($host,2)) {
open (A, ">>ping.log");
(
print A ("$CurrTime---$packed_ip_addr is active.
")
)} else
{
open (B ,">>ping.log");
(
print B ("$CurrTime---$host is lost.
") ,print "$host is lost.
"
)
}
sleep(5)
}}