Quantcast
Channel: Perl Modules – Erics Tech Blog
Viewing all articles
Browse latest Browse all 10

Sys::Hostname

$
0
0

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.

CPAN: Sys::Hostname

Example:
The one and only use for this module.

# 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";

Viewing all articles
Browse latest Browse all 10

Trending Articles