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

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: 8.163 UNIVERSAL Chapter 8
Standard Modules
Next: 8.165 User::pwent
 

8.164 User::grent

Overrides core getgrent , getgruid , and getgrnam functions with versions that return User::grent 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::grent; $gr = getgrgid(0) or die "No group zero"; if ( $gr->name eq 'wheel' && @{$gr->members} > 1 ) {     print "gid zero name wheel, with other members"; }
The field names (and therefore the method names) are the same as the names of the fields in the group structure from the C file grp.h : name , passwd , gid , and members (not mem ). The first three return scalars, the last an array reference. You can access the fields either with the methods or by importing the fields into your namespace with the :FIELDS import tag and prepending gr_ to the method name (for example, gr_name ).

Exports four functions:


Previous: 8.163 UNIVERSAL Perl in a Nutshell Next: 8.165 User::pwent
8.163 UNIVERSAL Book Index 8.165 User::pwent