[Chicago-talk] XBase.pm

fire at dls.net fire at dls.net
Thu May 27 09:51:51 CDT 2004


Perl Mongers,

I recently had to retrieve data from a handful of old dBase III+ or dBase IV data files and found the package XBase.pm to be exceedingly useful. While I found the documentation to be incomplete, I was still able to write this program without having to open up the source code. Here is the little program I wrote to convert a number of dBase files into tab-delimited text files.
Perhaps this will be useful to someone else who has old dBase files but not the ambition to try to hard to get the data out.

Bradley Slavik



# read_dbf.pl
use XBase;

my @commodity = qw(AG BC BO C KI MB S SM U2 US W);

for my $commodity (qw(AG BC BO C KI MB S SM U2 US W)) {
	my $table = new XBase "LDB$commodity.dbf" or die XBase->errstr;
	open STDOUT, ">LDB$commodity.txt" or die "Cannot open LDB$commodity.txt";
	print $table->header_info, "\n";
	#$table->dump_records("fs" => " | ", "rs" => " <-+\n", "fields" => [ "id", "msg" ]);
	$table->dump_records("fs" => "\t", "rs" => "\n");
	close STDOUT;
}





More information about the Chicago-talk mailing list