User::grent(3perl)
π User::grent β the by-name interface to Perl's built-in getgr*() functions π
okay bestie, so this is User::grent, straight out of the Perl Programmers Reference Guide, and it's giving "let me hold your group entries for you" energy. no cap. π
β¨ SYNOPSIS β¨
use User::grent;
my $gr = getgrgid(0) or die "No group zero";
if ( $gr->name eq 'wheel' && @{$gr->members} > 1 ) {
print "gid zero name wheel, with other members";
}
use User::grent qw(:FIELDS);
getgrgid(0) or die "No group zero";
if ( $gr_name eq 'wheel' && @gr_members > 1 ) {
print "gid zero name wheel, with other members";
}
my $gr = getgr($whoever);
like, look at that. three whole vibes in one code block. we love a versatile queen. π
πΈ DESCRIPTION πΈ
okay so here's the tea, bestie: by default this module's exports override the core getgrent(), getgrgid(), and getgrnam() functions. not in a rude way!! in a glow-up way. instead of whatever they used to give you, they now hand you back proper "User::grent" objects. β¨
and this object? oh she's stacked. she's got methods that return the similarly named structure field name from the C's passwd structure from grp.h. the fields are:
namepasswdgidmembers
and NOT mem, ok?? it's members. say it with me. members. π«Ά the first three β name, passwd, gid β hand you back scalars like normal, but members is out here giving array reference because she contains multitudes. π
π¦ the :FIELDS import tag π¦
you can also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (heads up bestie: this still overrides your core functions. she's committed. no half measures. π€)
access these fields as variables named with a preceding "gr_". so, like, "$group_obj->gid()" corresponds to $gr_gid when you import the fields. iconic. matching. coordinated. π
and array references? they're available as regular array variables too, so this:
@{ $group_obj->members() }
would simply be:
@gr_members
so much cleaner. so much less typing. we love efficiency. π
π§ the getgr() function π§
getgr() is a simple front-end β she's the receptionist at the front desk of this whole operation, honestly β and what she does is forward a numeric argument to getgrgid() and the rest to getgrnam(). if it looks like a number, it goes one way. if it doesn't, it goes the other way. boom. routed. π
π no core overrides? no problem π
so maybe you want this functionality but you're NOT about that override life. valid!! to access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their full qualified names. ngl that phrasing is a whole mood but the meaning is rock solid.
on the other hand, the built-ins are still available via the "CORE::" pseudo-package. they never left. they're just backstage. π
β NOTE β
while this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. fr fr. it's an implementation detail, not a promise. do not build your whole personality on it. π
π AUTHOR π
Tom Christiansen
the legend themselves. give them their flowers. π
perl v5.44.0 β dated 2026-10-17 β and you've been reading User::grent(3perl). that's the whole page, bestie, you ATE it. go forth and getgr responsibly. mwah. ππβ¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms