<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I'd like to add two columns to a current .dbf
file using the XBase perl module.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Could someone provide me a small piece of code to
accomplish this task.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>I'm not sure of the syntax for XBase to grab a row,
chop it into its fields, add 2 more fields to the array, repack it into the
xbase format then write it to a new .dbf (say ARGV[1]).</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>i.e. in plain text file say tab
delimited</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>if (!$ARGV[1])<BR>{<BR> print "\n Invalid
usage...Usage: add_columns.pl CURRENTFILE NEWFILE\n";<BR>
exit;<BR>}<BR>open(INPUT, $ARGV[0]) || die "Could not open
$ARGV[0]";<BR>open(OUTPUT, ">$ARGV[1]");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>while(<INPUT>)<BR>{<BR>
chomp();<BR> @fields = split(/\t/, $_); # tab delimited
data<BR> $fields[$#fields + 1] = "new data element 1"; #
add an element to the array<BR> $fields[$#fields + 1] = "new data element
2"; # add another element<BR> print
"@fields\n";<BR> $output_string = join "\t", @fields;<BR> print
OUTPUT
"$output_string\n";<BR>}<BR>close(INPUT);<BR>close(OUTPUT);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>I'd like to do the same with .dbfs (append two
columns to the current .dbf)</DIV></FONT>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Thank you</FONT></DIV>
<DIV><FONT face=Arial size=2>Steve Lehr</FONT></DIV></BODY></HTML>