---
name: "Sys::Hostname"
section: "3pm"
platform: "linux"
package: "perl-5.004-doc"
version: "5.004.05-6"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/Sys::Hostname/3pm"
---

# Sys::Hostname(3pm)

Try every conceivable way to get hostname

## NAME

Sys::Hostname - Try every conceivable way to get hostname

## SYNOPSIS

```
    use Sys::Hostname;
    $host = hostname;
```

## DESCRIPTION

Attempts several methods of getting the system hostname and then caches the result.  It tries `syscall(SYS_gethostname)`, `` `hostname` ``, `` `uname -n` ``, and the file */com/host*. If all that fails it `croak`s.

All nulls, returns, and newlines are removed from the result.

## AUTHOR

David Sundstrom \<*sunds@asictest.sc.ti.com*\>

Texas Instruments
