about

writing

contact

Sys::Hostname

By eric

2007-01-19

Description:Sys::Hostname is a relatively small, but very useful module. Just as the module name describes, it gets your system’s hostname. To paraphrase the module’s POD documentation, it will try every conceivable way to get the hostname of the current machine.

# Always be safe
use strict;
use warnings;
# Use the module
use Sys::Hostname;
# Get the hostname
my $host = Sys::Hostname::hostname();
# The above line can also be written as
#my $host = hostname;
print "You are on: $host\\n";