<pre name="code" class="sql">v-dev-redis01:/root# cat a1.pl
sub check_dns{
use LWP::UserAgent;
use Net::Ping;
$web = shift;
$p = Net::Ping->new("icmp");
if ($p->ping($web,2)){
return 1;
}
else {
return 0;
}} ;
$var=&check_dns("$ARGV[0]");
print "$var\n";
v-dev-redis01:/root# perl a1.pl www.zjtest.com
1
If a default timeout ($def_timeout) in seconds is provided, it is used when a timeout is not given to the ping() method (below). The timeout must be greater than 0 and the default, if
not specified, is 5 seconds.
jrhmpt01:/root# cat a3.pl
use Net::Ping;
$p = Net::Ping->new("icmp");
use Data::Dumper;
my $xx= Dumper($p);
print "111111111\n";
print $xx;
print "\n";
jrhmpt01:/root# perl a3.pl
111111111
$VAR1 = bless( {
'proto_num' => 1,
通过Net::Ping 理解Perl的面向对象
最新推荐文章于 2021-02-04 11:12:18 发布