February 2012
Intermediate to advanced
1184 pages
37h 17m
English
gethostent
sethostent STAYOPEN
endhostentThese functions 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 gethostent
should not be considered portable. If a machine uses a name server, it
would have to interrogate most of the Internet to try to satisfy a
request for all the addresses of every machine on the planet. So
gethostent is unimplemented on such
machines. See gethostent(3) for other
details.
The Net::hostent module supports a by-name interface to this
function.
Read now
Unlock full access