@@ -22,7 +22,7 @@ use Time::HiRes;
2222@ISA = qw( Exporter) ;
2323@EXPORT = qw( pingecho) ;
2424@EXPORT_OK = qw( wakeonlan) ;
25- $VERSION = " 2.74 " ;
25+ $VERSION = " 2.75 " ;
2626
2727# Globals
2828
@@ -1081,8 +1081,7 @@ sub tcp_connect
10811081
10821082sub DESTROY {
10831083 my $self = shift ;
1084- if ($self -> {' proto' } eq ' tcp' &&
1085- $self -> {' tcp_chld' }) {
1084+ if ($self -> {' proto' } && ($self -> {' proto' } eq ' tcp' ) && $self -> {' tcp_chld' }) {
10861085 # Put that choking client out of its misery
10871086 kill " KILL" , $self -> {' tcp_chld' };
10881087 # Clean off the zombie
@@ -2004,13 +2003,13 @@ Net::Ping - check a remote host for reachability
20042003
20052004 use Net::Ping;
20062005
2007- $p = Net::Ping->new();
2006+ my $p = Net::Ping->new();
20082007 print "$host is alive.\n" if $p->ping($host);
20092008 $p->close();
20102009
2011- $p = Net::Ping->new("icmp");
2010+ my $p = Net::Ping->new("icmp");
20122011 $p->bind($my_addr); # Specify source interface of pings
2013- foreach $host (@host_array)
2012+ foreach my $host (@host_array)
20142013 {
20152014 print "$host is ";
20162015 print "NOT " unless $p->ping($host, 2);
@@ -2019,11 +2018,11 @@ Net::Ping - check a remote host for reachability
20192018 }
20202019 $p->close();
20212020
2022- $p = Net::Ping->new("icmpv6");
2023- $ip = "[fd00:dead:beef::4e]";
2021+ my $p = Net::Ping->new("icmpv6");
2022+ my $ip = "[fd00:dead:beef::4e]";
20242023 print "$ip is alive.\n" if $p->ping($ip);
20252024
2026- $p = Net::Ping->new("tcp", 2);
2025+ my $p = Net::Ping->new("tcp", 2);
20272026 # Try connecting to the www port instead of the echo port
20282027 $p->port_number(scalar(getservbyname("http", "tcp")));
20292028 while ($stop_time > time())
@@ -2035,19 +2034,19 @@ Net::Ping - check a remote host for reachability
20352034 undef($p);
20362035
20372036 # Like tcp protocol, but with many hosts
2038- $p = Net::Ping->new("syn");
2037+ my $p = Net::Ping->new("syn");
20392038 $p->port_number(getservbyname("http", "tcp"));
2040- foreach $host (@host_array) {
2039+ foreach my $host (@host_array) {
20412040 $p->ping($host);
20422041 }
2043- while (($host,$rtt,$ip) = $p->ack) {
2042+ while (my ($host, $rtt, $ip) = $p->ack) {
20442043 print "HOST: $host [$ip] ACKed in $rtt seconds.\n";
20452044 }
20462045
20472046 # High precision syntax (requires Time::HiRes)
2048- $p = Net::Ping->new();
2047+ my $p = Net::Ping->new();
20492048 $p->hires();
2050- ($ret, $duration, $ip) = $p->ping($host, 5.5);
2049+ my ($ret, $duration, $ip) = $p->ping($host, 5.5);
20512050 printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n",
20522051 1000 * $duration)
20532052 if $ret;
0 commit comments