NAME

Gedcom::Item - a base class for Gedcom::Grammar and Gedcom::Record

Version 1.05 - 20th July 1999

SYNOPSIS

use Gedcom::Record;

$self->{grammar} = Gedcom::Grammar->new(file     => $self->{grammar_file},
                                        callback => $self->{callback})
my $c = $self->copy
$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)
$item->print
my $child = get_child("CHIL2")
my @children = get_children("CHIL")
my $v = level
my $v = xref
my $v = tag
my $v = value
my $v = min
my $v = max
my $v = gedcom
my $v = file
my $v = line

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->{gedcom}

The top level gedcom object.

$item->{file}

The file from which this object was read, if any.

$item->{line}

The line number from which this object was read, if any.

$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.

copy

my $c = $self->copy

Make a copy of the object. The children are copied too.

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

print

$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.

Access functions

my $v = level
my $v = xref
my $v = tag
my $v = value
my $v = min
my $v = max
my $v = gedcom
my $v = file
my $v = line

Return the eponymous hash element.