Tutorials Point


  Perl Home

  PERL Functions

© 2013 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL setgrent Function



Advertisements

Syntax

setgrent


Definition and Usage

Sets (or resets) the enumeration to the beginning of the set of group entries. This function should be called before the first call to getgrent.

Return Value

  • Nothing

Example

Try out following example:

#!/usr/bin/perl -w

while( ($name,$passwd,$gid,$members) = getgrent() ){
   print "Name  = $name\n";
   print "Password  = $passwd\n";
   print "GID  = $gid\n";
   print "Members  = $members\n";
}

setgrent();    # Set the beginnging of the group database;

print "Again reading /etc/passwd file\n";
while( ($name,$passwd,$gid,$members) = getgrent() ){
   print "Name  = $name\n";
   print "Password  = $passwd\n";
   print "GID  = $gid\n";
   print "Members  = $members\n";
}

endpwent;  #claose the database;
	
}


Advertisements


  

Advertisements