summaryrefslogtreecommitdiff
path: root/lib/Sys
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-03-14 02:36:04 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-03-14 02:36:04 +0000
commitc5f45532ed2b51b2f17fa4a91b637da3665006fc (patch)
treea1e0fca3c02f89083f2e4b0d425a6fa22ac71278 /lib/Sys
parent49da0595a758084ead0616930380fee60b25aece (diff)
downloadperl-c5f45532ed2b51b2f17fa4a91b637da3665006fc.tar.gz
Use $^O; update VMS support
Diffstat (limited to 'lib/Sys')
-rw-r--r--lib/Sys/Hostname.pm7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Sys/Hostname.pm b/lib/Sys/Hostname.pm
index 457bf1a170..2c40361b51 100644
--- a/lib/Sys/Hostname.pm
+++ b/lib/Sys/Hostname.pm
@@ -1,7 +1,6 @@
package Sys::Hostname;
use Carp;
-use Config;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(hostname);
@@ -37,10 +36,11 @@ sub hostname {
# method 1 - we already know it
return $host if defined $host;
- if ($Config{'osname'} eq 'VMS') {
+ if ($^O eq 'VMS') {
# method 2 - no sockets ==> return DECnet node name
- if (!$Config{'d_has_sockets'}) { return $host = $ENV{'SYS$NODE'}; }
+ eval {gethostbyname('me')};
+ if ($@) { return $host = $ENV{'SYS$NODE'}; }
# method 3 - has someone else done the job already? It's common for the
# TCP/IP stack to advertise the hostname via a logical name. (Are
@@ -56,6 +56,7 @@ sub hostname {
return $host if $host;
# rats!
+ $host = '';
Carp::croak "Cannot get host name of local machine";
}