FlatFile
view release on metacpan or search on metacpan
FlatFile.pm view on Meta::CPAN
may want your custom class to inherit from
C<FlatFile::Rec>.
=cut
my $classid = "A";
sub new {
my ($class, %opts) = @_;
my $self = {recno => 0};
bless $self => $class;
# acquire object properties from argument list (%opts)
# or from class defaults or default defaults, as appropriate.
# _default will detect missing required values
# and unknown key names
for my $source (\%opts, $class->_classvars) {
$self->_acquire_settings($source, check_keys => 1);
}
# TODO: TESTS for this logic
FlatFile.pm view on Meta::CPAN
my $msg = "required field '$f' missing from record";
$msg .= " $id" if $id;
croak $msg;
}
}
}
$self->{data} = \%data;
$self->{db} = $db;
$self->{id} = $id;
bless $self => $class;
}
=head2 C<< $record->db >>
Returns the database object from which the record was originally selected.
This example shows how one might modify a record and then write the
change to disk, even if the original database object was unavailable:
$employee->set_salary(1.06 * $employee->salary);
$employee->db->flush;
FlatFile.pm view on Meta::CPAN
}
package FlatFile::Position;
sub new {
my ($class, $record_number_ref) = @_;
my $recno = $$record_number_ref;
my $self = sub {
$$record_number_ref = $recno;
};
bless $self => $class;
}
sub DESTROY {
my $self = shift;
$self->();
}
1;
__END__
( run in 0.331 second using v1.01-cache-2.11-cpan-3b35f9de6a3 )