1User::grent(3pm)       Perl Programmers Reference Guide       User::grent(3pm)
2
3
4

NAME

6       User::grent - by-name interface to Perl's built-in getgr*() functions
7

SYNOPSIS

9        use User::grent;
10        $gr = getgrgid(0) or die "No group zero";
11        if ( $gr->name eq 'wheel' && @{$gr->members} > 1 ) {
12            print "gid zero name wheel, with other members";
13        }
14
15        use User::grent qw(:FIELDS);
16        getgrgid(0) or die "No group zero";
17        if ( $gr_name eq 'wheel' && @gr_members > 1 ) {
18            print "gid zero name wheel, with other members";
19        }
20
21        $gr = getgr($whoever);
22

DESCRIPTION

24       This module's default exports override the core getgrent(), getgruid(),
25       and getgrnam() functions, replacing them with versions that return
26       "User::grent" objects.  This object has methods that return the
27       similarly named structure field name from the C's passwd structure from
28       grp.h; namely name, passwd, gid, and members (not mem).  The first
29       three return scalars, the last an array reference.
30
31       You may also import all the structure fields directly into your
32       namespace as regular variables using the :FIELDS import tag.  (Note
33       that this still overrides your core functions.)  Access these fields as
34       variables named with a preceding "gr_".  Thus, "$group_obj->gid()"
35       corresponds to $gr_gid if you import the fields.  Array references are
36       available as regular array variables, so "@{ $group_obj->members() }"
37       would be simply @gr_members.
38
39       The getpw() function is a simple front-end that forwards a numeric
40       argument to getpwuid() and the rest to getpwnam().
41
42       To access this functionality without the core overrides, pass the "use"
43       an empty import list, and then access function functions with their
44       full qualified names.  On the other hand, the built-ins are still
45       available via the "CORE::" pseudo-package.
46

NOTE

48       While this class is currently implemented using the Class::Struct
49       module to build a struct-like class, you shouldn't rely upon this.
50

AUTHOR

52       Tom Christiansen
53
54
55
56perl v5.26.3                      2018-03-01                  User::grent(3pm)
Impressum