Set::NestedGroups - grouped data eg ACL's, city/state/country etc
$nested = new Set::NestedGroups;
Set::NestedGroups gives an implementation of nested groups, access control lists (ACLs) would be one example of nested groups.
For example, if Joe is a Manager, and Managers have access to payroll, you can create an ACL which implements these rules, then ask the ACL if Joe has access to payroll.
Another example, you may wish to track which city, state and country people are in, by adding people to cities, cities to states, and states to countries.
creates a new Set::NestedGroups object.
creates a new Set::NestedGroups object, the object will be initialized using data read from this handle. For details on the format, see the save() method
creates a new Set::NestedGroups object, the object will be initialized using data read using this this DBI statement handle. For details on the format, see the save() method
adds a member to a group. The group will be created if it doesn't already exist.
removes a member from a group. If this was the last member in this group, then the group will be deleted. If the member was only in this group, then the member will be deleted.
Outputs the object to the given filehandle, which must be already open in write mode.
The format is compatable with the format used by CGI, and can be used with new to initialize a new object;
Returns true if successfully wrote the data, or false if something went wrong (usually that meant that the handle wasn't already open in write mode).
Saves the object to a DBI database. This can be used with new to initialize a new object. The $sth should be expecting 2 values, in this fashion:
$sth = $dbh->prepare('insert into acl values (?,?)')
$sth = $dbh->prepare('select * from acl');
Returns true if successfully wrote the data, or false if something went wrong.
Returns true if $member is a member of $group.
returns true if $member exists in any group.
returns true if $group exists
Returns the groups that $member belongs to. Options are explained below.
Returns the members of $group. Keep on reading for the options
Returns a Set::NestedGroups::Member object that will output an list of the members & groups. This could be considered a calling of groups() on each member, except this is more efficent.
The object can be used as follows.
By default, the above methods give every valid combination. However you might not always want that. Therefore there are options which can prevent return of certain values.
All of these examples presume that 'joe' is a member of 'managers', and 'managers' is a member of payroll, and that you are using only one of these options. You can use all 3, but that gets complicated to explain.
No Recursion is performed, method would ignore payroll, and return only managers.
Doesn't returns groups 'in the middle', method would ignore mangers, and return only payroll.
Doesn't return members that are groups. This only applies to the list() method, in which case it acts like nomiddles, except on the member instead of the group. list would ignore managers and return joe => managers , joe => payroll.
This sounds a lot more confusing than it actually is, once you try it once or twice you'll get the idea.
Alan R. Barclay, email@example.com
perl(1), CGI, DBI.
4 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
=back doesn't take any parameters, but you said =back 2
=back without =over
To install Set::NestedGroups, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.