Gedcom::Item - a base class for Gedcom::Grammar and Gedcom::Record
Version 1.04 - 29th May 1999
use Gedcom::Record; $self->{grammar} = Gedcom::Grammar->new(file => $self->{grammar_file}, callback => $self->{callback}); $self->read if $self->{file}; $self->add_children($rec) while (my $next = $self->next_record($record)) $line = $self->next_line my $line = $self->next_text_line $record->>write($fh, $level) $record->normalise_dates($format) $item->print my $child = get_child("CHIL2") my @children = get_children("CHIL")
A selection of subroutines to handle items in a gedcom file.
Some of the more important hash members are:
The level of the item.
The cross reference, either hard or soft.
The name of the tag.
The value of the item.
The minimum number of items allowed.
The maximum number of items allowed.
Array of all children of this item.
$self->{grammar} = Gedcom::Grammar->new(file => $self->{grammar_file}, callback => $self->{callback});
Create a new object.
If file is supplied, it is the name of a file to read.
If callback is supplied, it is a subroutine reference which is called at various times while the file is being read.
The subroutine takes five parameters: $title: A title $txt1: One text message $txt2: A secondary text message $current: A count of how far through the file we are $total: The extent of the file
The subroutine should return true iff the file shuld continue to be read.
$self->read if $self->{file};
Read a file into the object. Called by the constructor.
$self->add_children($rec)
Read in the children of a record.
while (my $next = $self->next_record($record))
Read the next record from a file. Return the record or false if it cannot be read.
$line = $self->next_line
Read the next line from the file, and return it or false.
my $line = $self->next_text_line
Read the next line of text from the file, and return it or false.
$record->>write($fh, $level)
Write the record to a FileHandle.
The subroutine takes two parameters: $fh: The FileHandle to which to write $level: The level of the record
$record->normalise_dates($format)
Change the format of all dates in the record.
See the documentation for Gedcom::normalise_dates
$item->print
Print the item. Used for debugging. (What? There are bugs?)
my $child = get_child("CHIL2")
Get a specific child from the item.
The argument contains the name of the tag, and optionally the count. The regular expression to generate the tag and the count is:
my ($tag, $count) = $t =~ /^_?(\w+?)(\d*)$/;
Returns the child, or undef if it doesn't exist;
my @children = get_children("CHIL")
Get all children matching a specified tag.
To install Gedcom, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Gedcom
CPAN shell
perl -MCPAN -e shell install Gedcom
For more information on module installation, please visit the detailed CPAN module installation guide.