[Chapter 8] 8.165 User::pwent
Author: Ellen Siever, Stephen Spainhour & Nathan Patwardhan
Date: 1999-07-02T01:55:22Z

#

| Chapter 8 Standard Modules |

## 8.165 User::pwent

Overrides core `getpwent`, `getpwuid`, and `getpwnam` functions with versions that return User::pwent objects. The object returned has methods with the same names as the structure fields they return. That is, to return the field name, use the `name` method:

>     use User::pwent;
>     $pw = getpwnam('daemon') or die "No daemon user";
>     if ( $pw->uid == 1 && $pw->dir =~ m#^/(bin|tmp)?$# ) {
>         print "gid 1 on root dir";
>     }

The field names (and therefore the method names) are the same as the names of the fields in the passwd structure from the C file pwd.h: name, passwd, uid, gid, quota, comment, gecos, dir, and shell. You can access the fields either with the methods or by importing the fields into your namespace with the :FIELDS import tag and prepending `pw_` to the method name (for example, `pw_name`).

Exports four functions:

- getpw
- getpwent
- getpwnam
- getpwuid

8.164 User::grent |  | 8.166 vars