<!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&nbsp;to add two columns to a current .dbf 
file using the XBase perl module.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Could someone provide me a small piece of code to 
accomplish this task.</FONT></DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>i.e. in plain&nbsp;text file say tab 
delimited</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>if (!$ARGV[1])<BR>{<BR>&nbsp; print "\n Invalid 
usage...Usage:&nbsp; add_columns.pl CURRENTFILE NEWFILE\n";<BR>&nbsp; 
exit;<BR>}<BR>open(INPUT, $ARGV[0]) || die "Could not open 
$ARGV[0]";<BR>open(OUTPUT, "&gt;$ARGV[1]");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>while(&lt;INPUT&gt;)<BR>{<BR>&nbsp; 
chomp();<BR>&nbsp; @fields = split(/\t/, $_);&nbsp; # tab delimited 
data<BR>&nbsp; $fields[$#fields + 1] = "new data element 1";&nbsp;&nbsp;&nbsp; # 
add an element to the array<BR>&nbsp; $fields[$#fields + 1] = "new data element 
2";&nbsp;&nbsp;&nbsp; # add another element<BR>&nbsp; print 
"@fields\n";<BR>&nbsp; $output_string = join "\t", @fields;<BR>&nbsp; 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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thank you</FONT></DIV>
<DIV><FONT face=Arial size=2>Steve Lehr</FONT></DIV></BODY></HTML>