home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeJava and XSLTSearch this book

8.229. 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 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.



Frontend that forwards a numeric arg to getgrid and other args to getgrname.


$gr = getgrent(  )

Successive calls to getgrent return objects representing successive entries from the group file.


$gr = getgrgid(gid)

Accesses the group file by group ID gid.


$gr = getgrnam(gname)

Accesses the group file by group name gname.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.