Полезная информация

Programming Perl

Programming PerlSearch this book
Previous: 3.2.48 gethostbynameChapter 3
Functions
Next: 3.2.50 getlogin
 

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.


Previous: 3.2.48 gethostbynameProgramming PerlNext: 3.2.50 getlogin
3.2.48 gethostbynameBook Index3.2.50 getlogin