From: Jarkko Hietaniemi Date: Mon, 22 Oct 2001 18:34:54 +0000 (+0000) Subject: Be more robust if no hostname or domainname X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bebec187884d6336c8cee5b277ee8977d16aae6f;p=p5sagit%2Fp5-mst-13.2.git Be more robust if no hostname or domainname (especially the latter) p4raw-id: //depot/perl@12570 --- diff --git a/lib/Net/Domain.pm b/lib/Net/Domain.pm index 03c24da..bd57996 100644 --- a/lib/Net/Domain.pm +++ b/lib/Net/Domain.pm @@ -224,13 +224,14 @@ sub domainname { # eleminate DNS lookups return $fqdn = $host . "." . $domain - if($host !~ /\./ && $domain =~ /\./); + if(defined $host && defined $domain && + $host !~ /\./ && $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 && $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