Copyright © tutorialspoint.com

PERL setnetent Function


Syntax

setnetent STAYOPEN


Definition and Usage

As getnetent() retriews the information fro the next line in the network database, then setnetent sets (or resets) the enumeration to the beginning of the set of host entries. This function should be called before the first call to getnetent. The STAYOPEN argument is optional and unused on most systems.

Return Value

  • Nothing

Example

Try out 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";
}

setnetent(1); # Rewind the database;

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

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

endnetent();  # Closes the database;

Copyright © tutorialspoint.com