sub ping { my ($self, $host, # Name or IP number of host to ping $timeout, # Seconds after which ping times out ) = @_; my ($ip, # Packed IP number of $host $ret, # The return value $ping_time, # When ping began ); croak("Usage: \$p->ping(\$host [, \$timeout])") unless @_ == 2 || @_ == 3; $timeout = $self->{"timeout"} unless $timeout; croak("Timeout must be greater than 0 seconds") if $timeout <= 0; $ip = inet_aton($host); return () unless defined($ip); # Does host exist? $ping_time = &time(); $ret = $self->{func}->( $self, $ip, $timeout ); return wantarray ? ($ret, &time() - $ping_time, $self->ntop($ip)) : $ret; }