Copyright © tutorialspoint.com

PERL gethostent Function


Syntax

gethostent


Definition and Usage

Iterates over the entries in the host file. Returns the following in a list context:

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

Return Value

  • In scalar context undef on error otherwise Host name.

  • In list context empty list on error otherwise host record (name, aliases, address type, length, list of addresses)

Example

Try following example:

#!/usr/bin/perl

while( ($name, $aliases, $addrtype, $length, @addrs) = gethostent() ){
   print "Name  = $name\n";
   print "Aliases  = $aliases\n";
   print "Addr Type  = $addrtype\n";
   print "Length  = $length\n";
   print "Addrs  = @addrs\n";
}


Copyright © tutorialspoint.com