Reputation: 85476
How can I get the current machine hostname in Perl? I'm looking for a way that works both in Linux and Windows.
With a websearch I found the module Sys::Hostname, however I can't install it
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
My Perl version for this test is 5.10.1 on Linux Ubuntu, and I will use Strawberry Perl on windows.
Upvotes: 1
Views: 3553
Reputation: 61369
It's telling you that it's already installed; Sys::Hostname
has been part of the Perl distribution for years. You can rely on it being installed unless the machine was last updated somewhere in the early 90s.
Upvotes: 7