GENDLIB(3)
β¨ GENDLIB β¨
okay so bestie, welcome to gendlib β it's the perl library for querying the genders file, and yes the name is giving "gender studies elective" but it's actually about clusters, i promise π (the manual page lives in section 3, hence the (3), iykyk)
π SYNOPSIS π
require "/usr/lib/genders/gendlib.pl";
that's it. that's the whole vibe. one require and you're in π«Ά
πΈ DESCRIPTION πΈ
so this package is a lil bundle of common functions for manipulating the genders file. and like β previously this code existed only in the nodeattr command, which was lowkey tragic, because apps that have to call nodeattr over and over and over again would spend a genuinely upsetting amount of time just reading and parsing the genders file every single time. exhausting. not the vibe.
these functions fix that: on the first call they build an in-memory cache of genders, and then every call after that just references the in-memory copy. so it's fast. it's giving β¨optimizedβ¨. slay.
π§ Initialization
Genders::init([$path_genders])β this one is normally called internally for initialization, but you can call it externally with a non-default genders file path, and then all subsequent operations will use that non-default data instead. you can also call it more than once if you want to switch up which genders file you're working with. iconic, flexible, we love her π
π Simple Queries
Genders::hasattr($attribute, [$node])β returns1if the node has that attribute,0if it doesn't. if you don't specify a node, it just uses the local node. easy peasy.Genders::getattrval($attribute, [$node])β returns the value of the attribute held by the node, or an empty string if there's no value, or if the node doesn't even have that attribute. no node specified? local node. default behavior, we move.Genders::getnode([$attribute])β returns a list of nodes that have the attribute you asked for. and if you also give a value, like"attr=val", then only nodes with that exact attribute and value come back. if you pass no attribute at all,getnodeliterally returns every node listed in the genders file. the whole roster. periodt.Genders::getattr([$node])β returns a list of attributes held by the node. guess what happens if you don't specify a node. yeah. local node. you know the drill π
π§ Complex Queries
Genders::getallattr()β returns a list of all attributes in the genders file (one cluster only, bestie β just the one).Genders::get_node_hash(\%node)β grabs you a copy of a hash of attributes to node lists for the current cluster, aka a "hash of lists". and it makes sure keys exist for all possible attributes across clusters, even if they point to empty lists. no missing keys, no sad undef warnings. we're thorough like that π¦Genders::get_clusters()β returns a list where the local cluster name is the first and only element. and yes it returns a list instead of a scalar purely for backwards compatibility β don't @ me, it's legacy behavior and we respect her. if the local cluster name isn't known, you getnull. that's the whole story.Genders::gendexp($exp, [$node])β evaluates an expression involving genders attributes and hands you back the result. any legal perl expression is fair game here, as long as it uses numeric constants, genders attributes (which get converted into$variables), and these operators:!,||,&&,*,+,-,/. if$nodeisn't specified, it assumes the local host. go off, math queen π₯
π Conversion
Genders::to_altnames()β give it a list of hostnames as they appear in the genders file, and it gives you back a list of alternate names. on the SP, genders names are assumed to be theinitial_hostnames, and it uses the SDR to convert toreliable_hostnames. on other systems, it goes looking for the value of thealtnameattribute in the genders file instead. and if an input hostname just can't be converted? it's preserved in the output. no hostname left behind π«ΆGenders::to_gendnames()β this is the inverse of theto_altnames()function, bestie. performs the reverse operation. and just liketo_altnames(), if an input hostname can't be converted, it's preserved in the output. same energy, opposite direction π
π SEE ALSO
lowkey important reminder:libgenders(3)andLibgenders(3)are two different pages. capitalization matters. i don't make the rules, i just read them π
and that's the whole page, bestie!! this one came from LLNL, dated 10/10/97, and it's GENDLIB(3) β go query those genders files, you absolute main character πβπ
π¦ where this page comes from
- epel 10: genders-compat 1.28.1~^20231119git27b915d-5.el10_2 Β· GPL-2.0-only
- fedora 43: genders-compat 1.28.1~^20231119git27b915d-5.fc43 Β· GPL-2.0-only
- fedora 44: genders-compat 1.28.1~^20231119git27b915d-6.fc44 Β· GPL-2.0-only
- opensuse-leap 16.0: genders-perl-compat 1.32-bp160.1.11 Β· GPL-2.0-or-later
- opensuse-leap 16.0: genders-perl-compat 1.32-bp160.1.11 Β· GPL-2.0-or-later
- opensuse-leap 16.0: genders-perl-compat 1.32-bp160.1.11 Β· GPL-2.0-or-later
- opensuse-leap 16.0: genders-perl-compat 1.32-bp160.1.11 Β· GPL-2.0-or-later
- Copyright (C) 2007-2019 Lawrence Livermore National Security, LLC
- Copyright (C) 2001-2007 The Regents of the University of California
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms