Perl 校验命中的脚本

这个脚本无比的重要,虽然代码简单,但是在判断是否准确上,有着很重要的地位。

通过icmp和解析,它有一定意义所在。

mark!..

#!/usr/bin/perl
use Net::Ping;
sub icmp_domain{
     $k='true';
     local($host)=shift;
     $p=Net::Ping->new("icmp");
#@url=<>;
     $k='false' unless $p->ping($host,1);
#if($p->ping($host,1)){
#     print "yes\n";
#}else{
#     print "No\n";
#}
     return $k;
     $p->close();
}
sub domain_ip{
     local($host)=shift;
     $p=Net::Ping->new();
     $p->hires();
     ($ret,undef,$ip) = $p->ping($host, 1);
     $p->close();
     return $ip;
}
$ip=domain_ip('163.com');
print $ip;
$icmp=icmp_domain('waieufh290.com');
print $icmp;
原文地址:https://www.cnblogs.com/xiaoCon/p/3013834.html