当前位置:首页 » 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;