Copyright © tutorialspoint.com

PERL getnetent Function


Syntax

getnetent


Definition and Usage

Gets the next entry from the /etc/networks file, returning:

($name, $aliases, $addrtype, $net)

If /etc/networks file is empty then it would not return anything and call will fail.

Return Value

  • In scalar context undef on error otherwise Network Name.

  • In list context Empty list on error otherwise Network record (name, aliases, address type, network address).

Example

Try following example:

#!/usr/bin/perl

use Socket;

while ( ($name, $aliases, $addrtype, $net)  = getnetent() ){

   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Addrtype = $addrtype\n";
   print "Net = $net\n";
}


Copyright © tutorialspoint.com