From: Perl 5 Porters Date: Mon, 18 Mar 1996 01:22:30 +0000 (+0000) Subject: 5.002-style -w cleanup X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a79c16488c3741e2289afb3e862fe186c815046d;p=p5sagit%2Fp5-mst-13.2.git 5.002-style -w cleanup --- diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 92d595e..3ba88d5 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -3,33 +3,31 @@ package Net::Ping; # Authors: karrer@bernina.ethz.ch (Andreas Karrer) # pmarquess@bfsec.bt.co.uk (Paul Marquess) +require 5.002 ; require Exporter; +use strict ; +use vars qw(@ISA @EXPORT $VERSION $tcp_proto $echo_port) ; + @ISA = qw(Exporter); @EXPORT = qw(ping pingecho); -$VERSION = 1.00; +$VERSION = 1.01; use Socket 'PF_INET', 'AF_INET', 'SOCK_STREAM'; -require Carp ; - -use strict ; - -$Net::Ping::tcp_proto = (getprotobyname('tcp'))[2]; -$Net::Ping::echo_port = (getservbyname('echo', 'tcp'))[2]; +use Carp ; -# keep -w happy -$Net::Ping::tcp_proto = $Net::Ping::tcp_proto ; -$Net::Ping::echo_port = $Net::Ping::echo_port ; +$tcp_proto = (getprotobyname('tcp'))[2]; +$echo_port = (getservbyname('echo', 'tcp'))[2]; sub ping { - Carp::croak "ping not implemented yet. Use pingecho()"; + croak "ping not implemented yet. Use pingecho()"; } sub pingecho { - Carp::croak "usage: pingecho host [timeout]" - unless @_ == 1 || @_ == 2 ; + croak "usage: pingecho host [timeout]" + unless @_ == 1 or @_ == 2 ; my ($host, $timeout) = @_; my ($saddr, $ip); @@ -48,13 +46,13 @@ sub pingecho { return 0 unless $ip; # "no such host" - $saddr = pack('S n a4 x8', AF_INET, $Net::Ping::echo_port, $ip); + $saddr = pack('S n a4 x8', AF_INET, $echo_port, $ip); $SIG{'ALRM'} = sub { die } ; alarm($timeout); $ret = 0; eval <<'EOM' ; - return unless socket(PINGSOCK, PF_INET, SOCK_STREAM, $Net::Ping::tcp_proto) ; + return unless socket(PINGSOCK, PF_INET, SOCK_STREAM, $tcp_proto) ; return unless connect(PINGSOCK, $saddr) ; $ret=1 ; EOM