NAME
FlatFile::DataStore::Preamble - Perl module that implements a flat file data store preamble class.
SYNOPSYS
use FlatFile::DataStore::Preamble;
my $preamble = FlatFile::DataStore::Preamble->new( {
indicator => $indicator, # single-character crud flag
date => $date, # pre-formatted date
transnum => $transint, # transaction number (integer)
keynum => $keynum, # record sequence number (integer)
reclen => $reclen, # record length (integer)
thisfnum => $fnum, # file number (in base format)
thisseek => $datapos, # seek position (integer)
prevfnum => $prevfnum, # ditto these ...
prevseek => $prevseek,
nextfnum => $nextfnum,
nextseek => $nextseek,
user => $user_data, # pre-formatted user-defined data
} );
my $string = $preamble->string(); # e.g.,
# new preamble from existing preamble string
# e.g., something like "#WP2L000I000F00Tw1001XN1001Ha100228Test "
my $clone = FlatFile::DataStore::Preamble->new( { string => $string } );
DESCRIPTION
FlatFile::DataStore::Preamble - Perl module that implements a flat file data store preamble class. This class defines objects used by FlatFile::DataStore::Record and FlatFile::DataStore. So you will probably not ever call new() yourself, but you might call some of the accessors either directly or via a FF::DS::Record object;
A "preamble" is a string of fixed-length fields that precedes every record in a FlatFile::DataStore data file. In addition, this string constitutes the entry in the data store key file for each current record.
VERSION
FlatFile::DataStore::Preamble version 0.04
CLASS METHODS
FlatFile::DataStore::Preamble->new( $parms )
Constructs a new FlatFile::DataStore::Preamble object.
The parm $parms
is a hash reference containing key/value pairs to populate the preamble string. If there is a $parms-
{'string'}> value, it will be parsed into fields and the resulting key/value pairs will replace the $parms
hash reference.
OBJECT METHODS: ACCESSORS
The following methods set and return their respective attribute values if $value
is given. Otherwise, they just return the value.
$preamble->string( [$value] ); # full preamble string
$preamble->indicator( [$value] ); # single-character crud indicator
$preamble->date( [$value] ); # date as YYYY-MM-DD
$preamble->keynum( [$value] ); # record sequence number (integer)
$preamble->reclen( [$value] ); # record length (integer)
$preamble->transnum( [$value] ); # transaction number (integer)
$preamble->thisfnum( [$value] ); # file number (in base format)
$preamble->thisseek( [$value] ); # seek position (integer)
$preamble->prevfnum( [$value] ); # ditto these ...
$preamble->prevseek( [$value] ); #
$preamble->nextfnum( [$value] ); #
$preamble->nextseek( [$value] ); #
$preamble->user( [$value] ); # pre-formatted user-defined data
Note: the class code uses these accessors to set values in the object as it is assembling the preamble string in new(). Unless you have a really good reason, you should not set these values yourself (outside of a call to new()). For example: setting the date with date() will not change the date in the string
attribute.
In other words, even though these are read/write accessors, you should only use them for reading.
AUTHOR
Brad Baxter, <bbaxter@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Brad Baxter
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.