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"; }