Perl中当前机器的主机名

sti*_*vlo 0 linux windows perl

如何在Perl中获取当前计算机主机名?我正在寻找一种适用于Linux和Windows的方法.

使用websearch我找到了模块Sys :: Hostname,但我无法安装它

install Sys::Hostname
Going to read '/home/stivlo/.cpan/Metadata'
  Database was generated on Sat, 04 Jun 2011 15:27:16 GMT
Running install for module 'Sys::Hostname'
The most recent version "1.16" of the module "Sys::Hostname"
is part of the perl-5.13.11 distribution. To install that, you need to run
  force install Sys::Hostname   --or--
  install F/FL/FLORA/perl-5.13.11.tar.gz
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible
Failed during this command:
 FLORA/perl-5.13.11.tar.gz                    : make NO isa perl
Run Code Online (Sandbox Code Playgroud)

我在这个测试的Perl版本在Linux Ubuntu上是5.10.1,我将在Windows上使用Strawberry Perl.

gee*_*aur 5

它告诉你它已经安装好了; Sys::Hostname多年来一直是Perl发行版的一部分.您可以依赖它进行安装,除非机器是在90年代早期的某个地方进行的.