Copyright © tutorialspoint.com

PERL setprotoent Function


Syntax

setprotoent STAYOPEN


Definition and Usage

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

Return Value

  • Nothing

Example

Try out following example:

#!/usr/bin/perl

while(($name, $aliases, $protocol_number) = getprotoent()){
   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Protocol Number = $protocol_number\n";
}

setprotoent(1); # Rewind the database.

while(($name, $aliases, $protocol_number) = getprotoent()){
   print "Name = $name\n";
   print "Aliases = $aliases\n";
   print "Protocol Number = $protocol_number\n";
}
endprotoent();  # Closes the database

Copyright © tutorialspoint.com