Sys::Hostname#
📦 min
The name of the machine the program runs on.
hostname(), exported by default, returns the system’s host name (what gethostname(2) reports, the same as uname -n), and dies “Cannot get host name of local machine” if there is none. The first answer is kept in $Sys::Hostname::host and returned from then on; ghname() asks again every time.
This is Sys::Hostname 1.25; Sys/Hostname.pm is upstream’s, and its XS half is native.
Synopsis#
use Sys::Hostname;
my $host = hostname(); # e.g. "build-01"
my $now = Sys::Hostname::ghname(); # asked again, not cached
Differences from upstream#
None: upstream’s test passes unchanged (t/81-xs-native/Sys-Hostname/100-upstream-hostname.t), and the rest there checks against perl 5.44.
Functions#
Other Functions#
ghname#
ghname() - asks the operating system for the hostname, uncached.