X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FNet%2FDomain.pm;h=b79ec8fa073fddd4570b95e8b3ced211da349a80;hb=446eaa427e017001f2d47e21b0ad20ce965cd808;hp=03c24da4a071fd165b5544adb6b96dfd53ccbd52;hpb=06c7082d6226d352105bade1a7e185ff0a49e896;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Net/Domain.pm b/lib/Net/Domain.pm index 03c24da..b79ec8f 100644 --- a/lib/Net/Domain.pm +++ b/lib/Net/Domain.pm @@ -16,7 +16,7 @@ use Net::Config; @ISA = qw(Exporter); @EXPORT_OK = qw(hostname hostdomain hostfqdn domainname); -$VERSION = "2.14"; # $Id: //depot/libnet/Net/Domain.pm#15 $ +$VERSION = "2.17"; # $Id: //depot/libnet/Net/Domain.pm#19 $ my($host,$domain,$fqdn) = (undef,undef,undef); @@ -127,6 +127,7 @@ sub _hostdomain { # those on dialup systems. local *RES; + local($_); if(open(RES,"/etc/resolv.conf")) { while() { @@ -143,7 +144,6 @@ sub _hostdomain { my $host = _hostname(); my(@hosts); - local($_); @hosts = ($host,"localhost"); @@ -165,7 +165,7 @@ sub _hostdomain { }; chop($dom = `domainname 2>/dev/null`) - unless(defined $dom || $^O eq 'MSWin32'); + unless(defined $dom || $^O =~ /^(?:cygwin|MSWin32)/); if(defined $dom) { my @h = (); @@ -224,13 +224,14 @@ sub domainname { # eleminate DNS lookups return $fqdn = $host . "." . $domain - if($host !~ /\./ && $domain =~ /\./); + if(defined $host and defined $domain + and $host !~ /\./ and $domain =~ /\./); # For hosts that have no name, just an IP address - return $fqdn = $host if $host =~ /^\d+(\.\d+){3}$/; + return $fqdn = $host if defined $host and $host =~ /^\d+(\.\d+){3}$/; - my @host = split(/\./, $host); - my @domain = split(/\./, $domain); + my @host = defined $host ? split(/\./, $host) : ('localhost'); + my @domain = defined $domain ? split(/\./, $domain) : (); my @fqdn = (); # Determine from @host & @domain the FQDN @@ -330,6 +331,6 @@ it under the same terms as Perl itself. =for html
-I<$Id: //depot/libnet/Net/Domain.pm#15 $> +I<$Id: //depot/libnet/Net/Domain.pm#19 $> =cut