NAME

XBase - Perl module for reading and writing the dbf files

SYNOPSIS

use XBase;
my $table = new XBase("dbase.dbf");
for (0 .. $table->last_record())
	{
	my ($deleted, $id, $msg)
		= $table->get_record($_, "ID", "MSG");
	print "$id:\t$msg\n" unless $deleted;
	}

DESCRIPTION

This module can read and write XBase database file, known as dbf in dBase and FoxPro world. It also reads memo (and the like) fields from the dbt files, if needed. This module should really be used via DBD::XBase DBI driver, but this is the alternative interface. Note for now: no DBD:: support currently exists.

Remember: Since the version number is pretty low now, you might want to check the CHANGES file any time you upgrade to see wheather some of the features you use haven't disappeared.

Warning for now: It doesn't support any index files at the present time! That means if you change your dbf, your idx&mdx will not match. So do not do that.

The following methods are supported:

new

Creates the XBase object, takes the file's name as argument, parses the file's header, fills the data structures.

close

Closes the object/file.

get_record

Returns data from the specified record (line of the table). The first argument is the number of the record. If there are any other arguments, they are considered to be the names of the fields and only the specified fields are returned. If no field names are present, returns all fields in the record. The first value of the returned list is the 1/0 value saying if the record is deleted or not.

last_record

Number of the last records in the file. The lines deleted but present in the file are included in this count.

last_field

Number of the last field in the file.

If the method fails (returns undef of null), the error message can be retrieved via errstr method. If the new method fails, you have no object and the you can get the error string in the $XBase::errstr variable.

The methods get_header_info and dump_records can be used to quickly view the content of the file. They are here mainly for debugging purposes so please do not rely on them.

For writing, you have methods:

write_record

As arguments, takes the number of the record and the list of values of the fields. It writes the record to the file. Unspecified fields (if you pass less than you should) are set to undef/empty. The record is undeleted.

write_record_hash

Takes number of the record and hash, sets the fields, unspecified are undeffed/emptied.

update_record_hash

Like write_record_hash but preserves fields that do not have value specified in the hash.

delete_record, undelete record

Deletes/undeletes the record.

There are following variables (parameters) in the XBase namespace that affect the internal behavior:

$DEBUG

Enables error messages on stderr.

$FIXERRORS

When reading the file, try to continue, even if there is some (minor) missmatch in the data.

$CLEARNULLS

If true, cuts off spaces and nulls from the end of character fields on read.

HISTORY

I have been using the Xbase(3) module by Pratap Pereira for quite a time to read the dbf files, but it had no writing capabilities, it was not -w/use strict clean and the author did not support the module behind the version 1.07. So I started to make my own patches and thought it would be nice if other people could make use of them. I thought about taking over the development of the original Xbase package, but the interface seemed rather complicated to me and I also disliked the licence Pratap had about the module.

So with the help of article XBase File Format Description by Erik Bachmann, URL ( http:// ... ), I have written a new module. It doesn't use any code from Xbase-1.07 and you are free to use and distribute it under the same terms as Perl itself.

Please send all bug reports CC'ed to my e-mail, since I might miss your post in c\.l\.p\.m(isc|odules) or dbi-users. Any comments from both Perl and XBase gurus are welcome, since I do neither use dBase nor Fox*, so there are probably pieces missing.

VERSION

0.024

AUTHOR

Jan Pazdziora, adelton@fi.muni.cz

SEE ALSO

perl(1), DBD::XBase(3), DBI(3)