summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-10-22 18:34:54 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-10-22 18:34:54 +0000
commitbebec187884d6336c8cee5b277ee8977d16aae6f (patch)
tree078299c98a738490752e4f0a162ef74d2df531ac
parentb6a0b9300b0eaf800e7a664e27d617bce6944c76 (diff)
downloadperl-bebec187884d6336c8cee5b277ee8977d16aae6f.tar.gz
Be more robust if no hostname or domainname
(especially the latter) p4raw-id: //depot/perl@12570
-rw-r--r--lib/Net/Domain.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Net/Domain.pm b/lib/Net/Domain.pm
index 03c24da4a0..bd5799601f 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