diff options
author | Graham Barr <gbarr@pobox.com> | 2001-10-22 21:45:02 +0000 |
---|---|---|
committer | Graham Barr <gbarr@pobox.com> | 2001-10-22 21:45:02 +0000 |
commit | 2c49bd1ad119155067137abcb0610678b9606ee1 (patch) | |
tree | 8030e0af12c4f288b85b7d445d8175c6b0eaf556 | |
parent | 22849b580fa5f9f198cdb454d36632b497807ae9 (diff) | |
download | perl-libnet-2c49bd1ad119155067137abcb0610678b9606ee1.tar.gz |
Net::Domain
- Be more robust if no hostname or domainname (especially the latter)
-rw-r--r-- | Net/Domain.pm | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Net/Domain.pm b/Net/Domain.pm index 4deb4c1..a1c6490 100644 --- a/Net/Domain.pm +++ b/Net/Domain.pm @@ -16,7 +16,7 @@ use Net::Config; @ISA = qw(Exporter); @EXPORT_OK = qw(hostname hostdomain hostfqdn domainname); -$VERSION = "2.15"; # $Id: //depot/libnet/Net/Domain.pm#16 $ +$VERSION = "2.16"; # $Id: //depot/libnet/Net/Domain.pm#17 $ my($host,$domain,$fqdn) = (undef,undef,undef); @@ -224,13 +224,14 @@ sub domainname { # eleminate DNS lookups return $fqdn = $host . "." . $domain - if($host && $domain && $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 && $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 <hr> -I<$Id: //depot/libnet/Net/Domain.pm#16 $> +I<$Id: //depot/libnet/Net/Domain.pm#17 $> =cut |