Genders(3) Perl library for querying a genders file

SYNOPSIS


use Genders;
$Genders::GENDERS_DEFAULT_FILE;
$obj = Genders->new([$filename])
$obj->debug($num)
$obj->getnodename()
$obj->getnodes([$attr, [$val]])
$obj->getattr([$node])
$obj->getattr_all()
$obj->getattrval($attr, [$node])
$obj->testattr($attr, [$node])
$obj->testattrval($attr, $val, [$node])
$obj->isnode([$node])
$obj->isattr($attr)
$obj->isattrval($attr, $val)
$obj->index_attrvals($attr)
$obj->query($query)
$obj->testquery($query, [$node])

DESCRIPTION

This package provides a perl interface for querying a genders file.
Genders->new([$filename])
Creates a Genders object and load genders data from the specified file. If the genders file is not specified, the default genders file will be used. Returns undef if file cannot be read.
$obj->debug($num)
Set the debug level in the genders object. By default, the debug level is 0 and all debugging is turned off. To turn it on, set the level to 1.
$obj->getnodename()
Returns the name of the current node.
$obj->getnodes([$attr, [$val]])
Returns a list of nodes with the specified attribute and value. If a value is not specified only the attribute is considered. If the attribute is not specified, all nodes listed in the genders file are returned.
$obj->getattr([$node])
Returns a list of attributes for the specified node. If the node is not specified, the local node's attributes returned.
$obj->getattr_all()
Returns a list of all attributes listed in the genders file.
$obj->getattrval($attr, [$node])
Returns the value of the specified attribute for the specified node. If the attribute does not exist or the attribute has no value, an empty string is returned. If the node is not specified, the local node's attribute value is returned.
$obj->testattr($attr, [$node])
Returns 1 if the specified node has the specified attribute, 0 if it does not. If the node is not specified, the local node is checked.
$obj->testattrval($attr, $val, [$node])
Returns 1 if the specified node has the specified attribute and value, 0 if it does not. If the node is not specified, the local node is checked.
$obj->isnode([$node])
Returns 1 if the specified node is listed in the genders file, 0 if it is not. If the node is not specified, the local node is checked.
$obj->isattr($attr)
Returns 1 if the specified attribute is listed in the genders file, 0 if it is not.
$obj->isattrval($attr, $val)
Returns 1 if the specified attribute is equal to the specified value for some node in the genders file, 0 if it is not.
$obj->index_attrvals($attr)
Internally indexes genders attribute values for faster search times. Subsequent calls with a different attribute will overwrite earlier indexes.
$obj->query($query)
Returns a list of nodes specified by a genders query. A genders query is based on the union, intersection, set difference, or complement between genders attributes and values. Union is represented by two pipe symbols ('||'), intersection by two ampersand symbols ('&&'), difference by two minus symbols ('--'), and complement by a tilde ('~') Operations are performed from left to right. Parentheses may be used to change the order of operations. For example, the following query would retrieve all nodes other than management or login nodes: ``all-(mgmt+login)''. If the query is not specified, all nodes listed in the genders file are returned.
$obj->testquery($query, [$node])
Returns 1 if the specified node meets the conditions of the specified query, 0 if it does not. If the node is not specified, the local node is checked.

AUTHOR

Albert Chu <[email protected]>