X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FNet%2Fnetent.pm;h=f7d32cb92542fb56af875ccc8bf4825627f3a68f;hb=ea5a7fad992230abd5ec11bf824bf8fd17832732;hp=9f385b06d16090ca288335d45ef8d1f0fbf9ba0d;hpb=36477c247f3c188fb8cc7e276c87b739d3e6ab7c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Net/netent.pm b/lib/Net/netent.pm index 9f385b0..f7d32cb 100644 --- a/lib/Net/netent.pm +++ b/lib/Net/netent.pm @@ -1,10 +1,11 @@ package Net::netent; use strict; +use 5.006_001; +our $VERSION = '1.00'; +our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); @EXPORT = qw(getnetbyname getnetbyaddr getnet); @EXPORT_OK = qw( $n_name @n_aliases @@ -14,7 +15,10 @@ BEGIN { } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'Net::netent' => [ name => '$', aliases => '@', @@ -90,7 +94,7 @@ $n_name if you import the fields. Array references are available as regular array variables, so for example C<@{ $net_obj-Ealiases() }> would be simply @n_aliases. -The getnet() funtion is a simple front-end that forwards a numeric +The getnet() function is a simple front-end that forwards a numeric argument to getnetbyaddr(), and the rest to getnetbyname(). @@ -113,30 +117,30 @@ The gethost() functions do this in the Perl core: That means that the address comes back in binary for the host functions, and as a regular perl integer for the net ones. This seems a bug, but here's how to deal with it: - + use strict; use Socket; use Net::netent; - + @ARGV = ('loopback') unless @ARGV; - + my($n, $net); - + for $net ( @ARGV ) { - + unless ($n = getnetbyname($net)) { warn "$0: no such net: $net\n"; next; } - + printf "\n%s is %s%s\n", $net, lc($n->name) eq lc($net) ? "" : "*really* ", $n->name; - + print "\taliases are ", join(", ", @{$n->aliases}), "\n" if @{$n->aliases}; - + # this is stupid; first, why is this not in binary? # second, why am i going through these convolutions # to make it looks right @@ -145,7 +149,7 @@ This seems a bug, but here's how to deal with it: shift @a while @a && $a[0] == 0; printf "\taddr is %s [%d.%d.%d.%d]\n", $n->net, @a; } - + if ($n = getnetbyaddr($n->net)) { if (lc($n->name) ne lc($net)) { printf "\tThat addr reverses to net %s!\n", $n->name; @@ -154,10 +158,10 @@ This seems a bug, but here's how to deal with it: } } } - + =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR