当前位置:首页 » Perl » Perl getpwent()函数

Perl getpwent()函数

perl getpwent()函数,getpwent()函数学习例子,getpwent()函数实例代码,getpwent()函数在线教程等

语法

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