getpwent |
返回下一个从/etc/passwd文件中的密码输入。这是使用结合迭代的密码文件与的setpwent和endpwent功能。 In a list context, returns在列表上下文中,返回
($name, $passwd, $uid, $gid, $quota, $comment, $gcos, $dir, $shell) = getpwent;
在标量上下文的用户名
在列表上下文中的用户记录 (name, password, user ID, group ID, quote, comment, real name, home directory, shell)
试试以下例子:
#!/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"; }