Tutorials Point


  Perl Home

  PERL Functions

© 2013 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL setpwent Function



Advertisements

Syntax

setpwent


Definition and Usage

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

Return Value

  • Nothing

Example

Try out following example:

#!/usr/bin/perl

while(($name, $passwd, $uid, $gid, $quota,
	$comment, $gcos, $dir, $shell) = getpwent()){
   print "Name = $name\n";
   print "Password = $passwd\n";
   print "UID = $uid\n";
   print "GID = $gid\n";
   print "Quota = $quota\n";
   print "Comment = $comment\n";
   print "Gcos = $gcos\n";
   print "HOME DIR = $dir\n";
   print "Shell = $shell\n";
}

setpwent() ; # Rewind the databse /etc/passwd

while(($name, $passwd, $uid, $gid, $quota,
        $comment, $gcos, $dir, $shell) = getpwent()){
   print "Name = $name\n";
   print "Password = $passwd\n";
   print "UID = $uid\n";
   print "GID = $gid\n";
   print "Quota = $quota\n";
   print "Comment = $comment\n";
   print "Gcos = $gcos\n";
   print "HOME DIR = $dir\n";
   print "Shell = $shell\n";
}

endpwent(); # Closes the database;


Advertisements


  

Advertisements