Article 24001 of comp.lang.perl:
Path: ig.co.uk!demon!news.sprintlink.net!pipex!uunet!haven.umd.edu!cs.umd.edu!mojo.eng.umd.edu!aria.eng.umd.edu!rensin
From:
[email protected] (David Rensin)
Newsgroups: comp.lang.perl
Subject: Re: Reading dBase .dbf files with perl
Date: 13 Nov 1994 23:12:34 GMT
Organization: Project GLUE, University of Maryland, College Park, MD
Lines: 68
Message-ID: <
[email protected]>
References: <
[email protected]>
NNTP-Posting-Host: aria.eng.umd.edu
X-Newsreader: TIN [version 1.2 PL1]
Randy Gregor (
[email protected]) wrote:
: Does anyone know of perl routines to read .dbf files?
: Thanks,
: --
: Randy Gregor, SunSoft L.A.
[email protected] 310-348-6037 (x46037)
The following is a shor perl prog I worte to read the structure of a .dbf.
Reading the records is simple after you know the structure.
-dave :-)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dave Rensin American Management Systems, Inc.
[email protected] Arlington, Va.
Regarding all oppinions expressed here:
"There mine.. All mine, I tell you!! Wooh Hoo..."
-Daffy Duck
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------CUT HERE ------------
#! /usr/local/bin/perl
open (dbf,$ARGV[0]) || die "shit.";
binmode(dbf);
read(dbf,$foo,32);
read(dbf,$foo,32);
while ($foo =~ /^\w/ && $foo !~ /^. /) {
$field_name = substr($foo,0,10);
$field_type = substr($foo,11,1);
$junk = substr($foo,12,1);
$field_position = unpack("C",$junk);
$junk = substr($foo,16,1);
$field_length = unpack("C",$junk);
write;
read(dbf,$foo,32);
}
print "\n";
format STDOUT_TOP =
Field Name Field Type Field Position Field Length