| Gedcom::Extra |
NAME
Gedcom::Extra - a module with extra methods for use with Paul Johnsons Gedcom module (download source)
AUTHOR
Bob Coret, http://www.coret.org
VERSION
v1.0 - 24th July 2003
SYNOPSIS
use Gedcom::Extra; # # Additions to Gedcom # my @children=$ged->couple_children($ind1,$ind2); my @places=$ged->places; my %places=$ged->enumerate_places; my @surnames=$ged->surnames([rewrite=>\&surname_rewrite]); my %surnames=$ged->enumerate_surnames([rewrite=>\&surname_rewrite]); $ged->may_publish($setting,@xrefarray); # # Additions to Gedcom::Individual # my $dateborn=$i->born; my $datedied=$i->died; my $lived = $i->lived; $i->count_ancestors(\@indivs_per_generation); $i->count_descendants(\@indivs_per_generation); my $forename = $i->forename; my $givenname = $i->givenname; my $fullname = $i->fullname; my $displayname = $i->displayname; my @irecords=$i->enumerate_events; my @halfsibling = $i->halfsiblings; my $may_publish=$i->may_publish; $i->may_publish($setting); my $pid = $i->pid; # # Additions to Gedcom::Family # my @familyevents=$family->enumerate_events;
DESCRIPTION
This module contains additional methods to Paul Johnsons Gedcom module (version 1.12). The latest version of that software is available from his homepage (http://www.pjcj.net) or from CPAN (www.cpan.org). I have made this module to add my own convenience (read) methods which I use to generate my genealogical site (http://www.coret.org).
INSTALLATION
Sorry, no installation script, just download then module and copy it in the directory where Paul Johnsons Gedcom modules reside (eg. \perl\site\lib\Gedcom\). For simple testing and to see working examples you can download testExtra.pl.
METHODS (in addition to Gedcom)
may_publish
my @extrapublish=("I3","I7");
$ged->may_public($setting,@extrapublish);
Set the may_publish flag to the $setting parameter for all indivuduals whose XREFs are in the given array. The may_pulish flag indicates that the information about an individuals may (1) or may not (0) be published.
couple_children
my @children=$ged->couple_children($ind1,$ind2);
Return an array with individuals which represent the children the two individuals share, usefull when individuals have children in more than one marriage (different famc's).
places
my @places=$ged->places;
Return an array with all the places used in individual and family events.
enumerate_places
my %places=$ged->enumerate_places;
Return a hash with all the places associated with individual and family events. The hash has a place name as key and the number of occurences as data member. Based on the example GEDCOM "royal.ged" the hash $places{'Westminster,Abbey,London,England'} would return 6.
Example usage:
#
# Print places and number of individuals with an event in the place,
# with a minumum of 10 events
#
my $min_events=10;
print "Places with $min_events or more events:\n";
my %places=$ged->enumerate_places;
print map { if ($places{$_}>$min_events) { $_." - ".$places{$_}."\n"} }
sort { $places{$b} <=> $places{$a} } keys %places;
surnames
my @surnames=$ged->surnames;
Return an array with the surnames of all individuals.
Optional parameter:
rewrite => reference to function which rewrites the surnames.
Example usage:
# # Print the number of distinct surnames in the GEDCOM # my @surnames=$ged->surnames; my $aantalsur=@surnames; print $aantalsur." surnames found";
surnames_rewrite
my $rewrittensurname=surnames_rewrite($surname);
Return the surname in rewritten form placing the prefixes and infixes at the end eg. 'van Buuren' becomes 'Buuren, van' and "l'Oreil" become "Oreil, l'". Usefull for sorting a list of surnames. See the array @surname_prefixes and @surname_infixes.
enumerate_surnames
my %surnames=$ged->enumerate_surnames;
Return a hash with surnames of all the individuals which may be published. The hash has a surname as key and the number of indivuduals with that surname as data member. Based on the example GEDCOM "royal.ged" the hash $surnames{'Windsor'} wourld return 29.
Optional parameter:
rewrite => reference to function which rewrites the surnames.
Example usage:
#
# Print a sorted list of family names which occur more then 10 times in the GEDCOM
#
my $min_indivs=10;
print "Families with $min_indivs or more individuals:\n";
my %surnames=$ged->enumerate_surnames(rewrite => \&Gedcom::surname_rewrite);
print map { if ($surnames{$_}>=$min_indivs) { $_." - ".$surnames{$_}."\n"} }
sort { $surnames{$b} <=> $surnames{$a} } keys %surnames;
METHODS (in addition to Gedcom::Individual)
GEDCOM record snippet used in the examples below:
# 0 @I000006@ INDI
# 1 NAME Alida Helena /van Buuren/
# 2 GIVN Alie
# 1 BAMP
# 2 DATE 1 Feb 1903
# 1 CREM
# 2 DATE 21 Sep 1984
#
my $gedcom = Gedcom->new(grammar_file => "....",gedcom_file => "....");
my $i = $gedcom->get_individual("I000006");
born
my $dateborn=$i->born;
Return the date the individual was approximately born by looking for a date of birth or date of baptism. Based on sample GEDCOM snippet the example above produces "1 Feb 1903".
died
my $datedied=$i->died;
Return the date the individual approximately died by looking for a date of death, date of burial or date of cremation. Based on sample GEDCOM snippet the example above produces "21 Sep 1984".
lived
my $lived = $i->lived;
Return a string with most probable year of birth and/or year of death in format "yyyy-yyyy". Based on sample GEDCOM snippet the example above produces "1903-1984".
count_ancestors
my @indivs_per_generation; $i->count_ancestors(\@indivs_per_generation);
Fills array with number of individual's ancestors per generation. So $indivs_per_generation[1] contains the number of parents, $indivs_per_generation[2] the number of grandparents, etc. $indivs_per_generation[0] contains the total number of ancestors.
Example usage:
#
# Print number and name of ancestors of the individual
#
my @generation_names=("me","parents","grandparents","great grandparents",
"2th great grandparents","3rd great grandparents");
for(6..24) { $generation_names[$_]=($_-2)."th great grandparents"; }
my @generation_numbers;
$i->count_ancestors(\@generation_numbers);
print $i->name." has ".$generation_numbers[0];
print " ancestors in ".($#generation_numbers)." generations:\n";
for (1..$#generation_numbers) {
print "- ".$generation_names[$_].": ".$generation_numbers[$_]."\n";
}
count_descendants
my @indivs_per_generation; $i->count_descendants(\@indivs_per_generation);
Fills array with the number of individual's descendants per generation. $indivs_per_generation[1] contains the number of children, $indivs_per_generation[2] the number of grandchildren, etc. $indivs_per_generation[0] contains the total number of descendants.
Example usage:
#
# Print number and name of ancestors of the individual
#
my @generation_names=("me","children","grandchildren","great grandchildren",
"2th great grandchildren","3rd great grandchildren");
for(6..24) { $generation_names[$_]=($_-2)."th great grandchildren"; }
my @generation_numbers;
$i->count_descendants(\@generation_numbers);
print $i->name." has ".$generation_numbers[0];
print " descendants in ".($#generation_numbers)." generations:\n";
for (1..$#generation_numbers) {
print "- ".$generation_numbers[$_]." ".$generation_names[$_]."\n";
}
forename
my $forename = $i->forename;
Return the forename of an individual. Based on sample GEDCOM snippet the example above produces "Alida Helena".
givenname
my $givenname = $i->givenname;
Return the given name of an individual if defined and not equal to first name. Based on sample GEDCOM snippet the example above produces "Alie".
fullname
my $fullname = $i->fullname;
Returns the individuals name including the given name between parentheses if applicable. Slashes around surname are removed. Based on sample GEDCOM snippet the example above produces "Alida Helena (Alie) van Buuren".
displayname
my $displayname = $i->displayname;
Returns the the name in display form (easy sortable), it consist of surname (rewritten), forename and givenname. Based on sample GEDCOM snippet the example above produces "Buuren, Alida Helena (Alie) van".
enumerate_events
my @irecords=$i->enumerate_events;
Return array of records containing information about all the events associated with an individual (birth, baptism, cremation, etc.).
Example usage:
#
# Print type, date and place of all teh events associated with the indivual
#
print "Individual events of ".$i->name.":\n";
for my $record ($i->enumerate_events) {
if ($record->{type} eq "EVEN") {
$type=$$Gedcom::Tags{$record->{event}->type};
} else {
$type=$$Gedcom::Tags{$record->{type}};
}
print "- ".join(" > ",$type,$record->{event}->date,$record->{event}->place)."\n";
}
halfsiblings
my @halfsibling = $i->halfsiblings;
Return an array of half brothers and half sisters (hence the name "halfsibblings") of the individual. Brothers and sisters (so sibblings with same parents as individual) are not included in the list.
may_publish
$i->set_may_publish(1) $may_pulish=$i->set_may_publish;
When no parameter is given the value of the may_publish flag is returned. If a parameter is given may_publish flag of individual is set to indicate tje information about the individual may (1) or may not (0) be published.
WARNING: local laws and genealogical customs dictates when a individuals information may be published. This method only checks is the person has died, born before 1900 or has given explicit permission.
pid
my $pid = $i->pid;
Return the identification number the individual in numerical form, this means without the I and preceding 0's. Based on sample GEDCOM snippet the example above produces "6".
METHODS (in addition to Gedcom::Family)
enumerate_events
my @familyevents=$family->enumerate_events;
Return array of Gedcom::Records containing information about all the events associated with a family (marriage, divorce, etc.).
Example usage:
#
# Print type, date and place of all teh events associated with the family
#
print "Family events of ".$i->name.":\n";
for my $fam ($i->fams) {
for my $record ($fam->enumerate_events) {
if ($record->{type} eq "EVEN") {
$type=$$Gedcom::Tags{$record->{event}->type};
} else {
$type=$$Gedcom::Tags{$record->{type}};
}
print "- ".join(" > ",$type,$record->{event}->date,$record->{event}->place)."\n";
}
}