NAME
Gedcom::Item - a base class for Gedcom::Grammar and Gedcom::Record
Version 1.02 - 5th May 1999
SYNOPSIS
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")
DESCRIPTION
A selection of subroutines to handle items in a gedcom file.
HASH MEMBERS
Some of the more important hash members are:
$item->{level}
The level of the item.
$item->{xref}
The cross reference, either hard or soft.
$item->{tag}
The name of the tag.
$item->{value}
The value of the item.
$item->{min}
The minimum number of items allowed.
$item->{max}
The maximum number of items allowed.
$item->{children}
Array of all children of this item.
METHODS
new
$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.
read
$self->read if $self->{file};
Read a file into the object. Called by the constructor.
add_children
$self->add_children($rec)
Read in the children of a record.
next_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.
next_line
$line = $self->next_line
Read the next line from the file, and return it or false.
next_text_line
my $line = $self->next_text_line
Read the next line of text from the file, and return it or false.
write
$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
normalise_dates
$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?)
get_child
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;
get_children
my @children = get_children("CHIL")
Get all children matching a specified tag.