DBD-XBase

 view release on metacpan or  search on metacpan

lib/XBase.pm  view on Meta::CPAN

622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# Write record, fields are specified as hash, unspecified are set to
# undef/empty
sub set_record_hash {
        my ($self, $num, %data) = @_;
        $self->NullError();
        $self->set_record($num, map { $data{$_} } $self->field_names );
}
 
# Write record, fields specified as hash, unspecified will be
# unchanged
sub update_record_hash {
        my ($self, $num) = ( shift, shift );
        $self->NullError();
 
        my %olddata = $self->get_record_hash($num);
        return unless %olddata;
        $self->set_record_hash($num, %olddata, @_);
}
 
# Actually write the data (calling XBase::Base::write_record) and keep
# the overall structure of the file correct;

lib/XBase.pm  view on Meta::CPAN

658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
        $self->NullError();
        $self->write_record($num, "*");
}
sub undelete_record {
        my ($self, $num) = @_;
        $self->NullError();
        $self->write_record($num, " ");
}
 
# Update the last change date
sub update_last_change {
        my $self = shift;
        return 1 if defined $self->{'updated_today'};
        my ($y, $m, $d) = (localtime)[5, 4, 3]; $m++; $y -= 100 if $y >= 100;
        $self->write_to(1, pack "C3", ($y, $m, $d)) or return;
        $self->{'updated_today'} = 1;
}
# Update the number of records
sub update_last_record {
        my ($self, $last) = @_;
        $last++;
        $self->write_to(4, pack "V", $last);
        $self->{'num_rec'} = $last;
}
 
# Creating new dbf file
sub create {
        XBase->NullError();
        my $class = shift;



( run in 1.065 second using v1.01-cache-2.11-cpan-49f99fa48dc )