michellem has asked for the wisdom of the Perl Monks concerning the following question:
I have what seems to me to be a straightforward task: to output the contents of an array of hashes into a DBF file via XBase.
I've been poring over the XBase Docs and FAQ and I can't seem to figure this out. The problem is that the object I should be creating with XBase, isn't recognized by XBase. Here's the code:
use XBase; ... my $new_table = XBase->create("name" => "$filename.$ext", "field_names" => @column_names, "field_types" => undef, "field_lengths" => undef, "field_decimals" => undef); my $i=0; foreach my $record (@records) { $new_table->set_record_hash($i,%$record); $i++; } $new_table->close;
The problem is, I get an error message: "Can't call method "set_record_hash" on an undefined value at /home/www/xina-cgi/libexec/xiexport.cgi line 264." Which I take to mean that it doesn't recognize $new_table as an XBase object.
So I thought that perhaps once I created the new table, I needed to define a new XBase object, and I tried this:
my $new_table = XBase->create("name" => "$filename.$ext", "field_names" => @column_names, "field_types" => undef, "field_lengths" => undef, "field_decimals" => undef); my $dbf = new XBase "$filename.$ext" or Xina::util::graceful_e +xit("xiexport","Problems with DBF file.","$filename.$ext:".XBase->err +str." from $remote_host"); my $i=0; foreach my $record (@records) { $dbf->set_record_hash($i,%$record); $i++; } $dbf->close;
Except now, I get the error: "Error opening file xxx.dbf: No such file or directory" - it doesn't create the file in the first place (I verified that by looking at the directory). But there is no error thrown on the create step. So I'm stumped. The directory is writeable, blah, blah, there are no file permission issues here.
Thanks for any pointers!
Michelle
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XBase File output
by Zaxo (Archbishop) on Feb 08, 2004 at 05:14 UTC | |
|
Re: XBase File output
by guha (Priest) on Feb 08, 2004 at 00:19 UTC | |
by michellem (Friar) on Feb 08, 2004 at 00:32 UTC | |
by guha (Priest) on Feb 08, 2004 at 00:44 UTC | |
by michellem (Friar) on Feb 08, 2004 at 05:05 UTC |