start page | rating of books | rating of authors | reviews | copyrights

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: getprotoent Chapter 5
Function Reference
Next: Reference: getpwnam
 

getpwent

getpwent

Retrieves the next line from the /etc/passwd file (or its equivalent coming from some server somewhere). Returns null at the end of the file. The return value in list context is:

($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell)
Some machines may use the quota and comment fields for other purposes, but the remaining fields will always be the same. To set up a hash for translating login names to uids, do this:
while (($name, $passwd, $uid) = getpwent) {     $uid{$name} = $uid; }
In scalar context, getpwent returns only the username.


Previous: Reference: getprotoent Perl in a Nutshell Next: Reference: getpwnam
Reference: getprotoent Book Index Reference: getpwnam