當前位置:首頁 » Perl » perl setpwent()函數

perl setpwent()函數

perl setpwent()函數例子,setpwent()函數實例代碼 - 集(或重置)的開頭的組的密碼條目的枚舉。

語法

setpwent


定義和用法

集(或重置)的開頭的組的密碼條目的枚舉。這個函數應該被調用之前在第一次調用getpwent。

返回值

  • Nothing

例子

試試下麵的例子:

#!/usr/bin/perl
#by www.gitbook.net

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
#by www.gitbook.net
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;