@@ -22,7 +22,7 @@ use Time::HiRes;
22
22
@ISA = qw( Exporter) ;
23
23
@EXPORT = qw( pingecho) ;
24
24
@EXPORT_OK = qw( wakeonlan) ;
25
- $VERSION = " 2.74 " ;
25
+ $VERSION = " 2.75 " ;
26
26
27
27
# Globals
28
28
@@ -1081,8 +1081,7 @@ sub tcp_connect
1081
1081
1082
1082
sub DESTROY {
1083
1083
my $self = shift ;
1084
- if ($self -> {' proto' } eq ' tcp' &&
1085
- $self -> {' tcp_chld' }) {
1084
+ if ($self -> {' proto' } && ($self -> {' proto' } eq ' tcp' ) && $self -> {' tcp_chld' }) {
1086
1085
# Put that choking client out of its misery
1087
1086
kill " KILL" , $self -> {' tcp_chld' };
1088
1087
# Clean off the zombie
@@ -2004,13 +2003,13 @@ Net::Ping - check a remote host for reachability
2004
2003
2005
2004
use Net::Ping;
2006
2005
2007
- $p = Net::Ping->new();
2006
+ my $p = Net::Ping->new();
2008
2007
print "$host is alive.\n" if $p->ping($host);
2009
2008
$p->close();
2010
2009
2011
- $p = Net::Ping->new("icmp");
2010
+ my $p = Net::Ping->new("icmp");
2012
2011
$p->bind($my_addr); # Specify source interface of pings
2013
- foreach $host (@host_array)
2012
+ foreach my $host (@host_array)
2014
2013
{
2015
2014
print "$host is ";
2016
2015
print "NOT " unless $p->ping($host, 2);
@@ -2019,11 +2018,11 @@ Net::Ping - check a remote host for reachability
2019
2018
}
2020
2019
$p->close();
2021
2020
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]";
2024
2023
print "$ip is alive.\n" if $p->ping($ip);
2025
2024
2026
- $p = Net::Ping->new("tcp", 2);
2025
+ my $p = Net::Ping->new("tcp", 2);
2027
2026
# Try connecting to the www port instead of the echo port
2028
2027
$p->port_number(scalar(getservbyname("http", "tcp")));
2029
2028
while ($stop_time > time())
@@ -2035,19 +2034,19 @@ Net::Ping - check a remote host for reachability
2035
2034
undef($p);
2036
2035
2037
2036
# Like tcp protocol, but with many hosts
2038
- $p = Net::Ping->new("syn");
2037
+ my $p = Net::Ping->new("syn");
2039
2038
$p->port_number(getservbyname("http", "tcp"));
2040
- foreach $host (@host_array) {
2039
+ foreach my $host (@host_array) {
2041
2040
$p->ping($host);
2042
2041
}
2043
- while (($host,$rtt,$ip) = $p->ack) {
2042
+ while (my ($host, $rtt, $ip) = $p->ack) {
2044
2043
print "HOST: $host [$ip] ACKed in $rtt seconds.\n";
2045
2044
}
2046
2045
2047
2046
# High precision syntax (requires Time::HiRes)
2048
- $p = Net::Ping->new();
2047
+ my $p = Net::Ping->new();
2049
2048
$p->hires();
2050
- ($ret, $duration, $ip) = $p->ping($host, 5.5);
2049
+ my ($ret, $duration, $ip) = $p->ping($host, 5.5);
2051
2050
printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n",
2052
2051
1000 * $duration)
2053
2052
if $ret;
0 commit comments