NAME

oEdtk::Record - a fixed-width record made of typed fields

SYNOPSIS

use oEdtk::Record;

my $rec = oEdtk::Record->new(@fields);   # oEdtk::Field objects
$rec->bind_all;
my %vals = $rec->parse($line);

DESCRIPTION

A record is an ordered sequence of typed fields (oEdtk::Field objects). It builds an unpack template from the field lengths, unpacks a raw line, and runs each bound field's process to produce a name-to-value hash.

METHODS

new

my $rec = oEdtk::Record->new(@fields);

Build a record from @fields. Every argument must be an oEdtk::Field, and a catch-all field (length *) must come last.

debug

$rec->debug;

Turn on the verbose bind_all output.

set_seek_key

$rec->set_seek_key($seek_key);

Set the regex used to find this record in the stream; defaults to the LIGNE... form.

set_fields_offset

$rec->set_fields_offset($offset);

Set the offset at which the fields start.

parse

my %values = $rec->parse($line);

Unpack $line and run each bound field's process, returning a hash of name-to-value pairs.

bind

$rec->bind(%rename);
$rec->bind;              # bind every field under its current name

Bind fields onto the record. With a name-to-new-name map, rename the matching fields; with no argument, bind every field so "parse" returns them all. Returns the record.

bind_all

$rec->bind_all;

Name each field after its longest --separated component and bind all of them.

AUTHOR

The oEdtk team.