Tree::Family::Person
my $p = Tree::Family::Person->new( first_name => 'Fred', last_name => 'Flintstone', birth_date => '1901-09-01', death_date => undef, gender => 'male', birth_place => 'Bedrock'); $p->spouse($wilma); $p->dad($papa); $p->mom($mama); for ($p->kids) { print $_->first_name; } $p->set(last_name => 'Smith');
Create a new person
Accessors, mutators
first + middle + last
Set an attribute for a person (same as using mutators above)
$person->set(first_name => 'Joe');
Get an attribute
Same as using accessors above.
$person->get('first_name');
Get/set spouse
$fred->spouse($wilma)
Get/set dad
$luke->dad($darth)
Get/set mom
$pebbles->mom($wilma)
Add a kid to a person
$carol->add_kid($jan); $carol->add_kid($marsha); $carol->add_kid($cindy);
Remove a kid from a person
$someone->remove_kid($annie)
Return an array of kids
print $_->name for $mike->kids
Did $a have any kids with $b?
print $a->has_partner($b) ? 'you betcha' : 'nope'
Get people with whom a person had kids.
Find a person based on their attributes
$class->find(first_name => "Bugs", last_name => "Bunny" );
Get all people
Tree::Family::Person->all
Get a list of all people with whom a person had kids, and their spouse (if they have one)
The min/max numeric generation
Used for storage by Data::Dumper.
To install Tree::Family, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Family
CPAN shell
perl -MCPAN -e shell install Tree::Family
For more information on module installation, please visit the detailed CPAN module installation guide.