Perl (Scripting) - hostname

by
Jeremy Canfield |
Updated: May 09 2024
| Perl (Scripting) articles
This assumes you have installed the Net::Domain module on your system.
Here is the boilerplate code to return the system hostname using Net::Domain.
#!/usr/bin/perl
use strict;
use warnings;
use Net::Domain qw(hostname);
my $hostname = hostname();
print "\$hostname = $hostname";
exit;
Did you find this article helpful?
If so, consider buying me a coffee over at