[Chapter 3] 3.2.49 gethostent
Author: Larry Wall, Tom Christiansen & Randal L. Schwartz
Date: 1999-07-02T01:50:20Z

#

| Chapter 3 Functions |

### 3.2.49 gethostent

    gethostent
    sethostent STAYOPEN
    endhostent

These functions do the same thing as their like-named system library routines - see gethostent(3).

They iterate through your /etc/hosts file and return each entry one at a time. The return value from gethostent is:

    ($name, $aliases, $addrtype, $length, @addrs)

where `@addrs` is a list of raw addresses. In the Internet domain, each address is four bytes long, and can be unpacked by saying something like:

    ($a, $b, $c, $d) = unpack('C4', $addrs[0]);

Scripts that use these routines should not be considered portable. If a machine uses a nameserver, it would interrogate most of the Internet to try to satisfy a request for all the addresses of every machine on the planet. So these routines are unimplemented on such machines.

3.2.48 gethostbyname |  | 3.2.50 getlogin