in reply to DBD::Anydata
Greetings,
I hope that I am not going to be wasting anyone's time here, however, I have not seen this addressed.
I am trying to implement jZed's DBD::AnyData module to parse a flat file db. My test code is:
#!/usr/bin/perl use strict; use warnings;use CGI::Carp qw(fatalsToBrowser); use DBI; use DBD::AnyData; print qq[content-type: text/html\n\n]; my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):'); my $table = 'mothers'; my $format = 'Pipe'; my $file = 'databases/mothers.tbl'; my $flags = ''; # The first row holds the field names $dbh->func( $table, $format, $file, $flags, 'ad_catalog'); my $sth = $dbh->prepare("SELECT * FROM mothers WHERE name = 'Sandra'") +; $sth->execute(); while (my $row = $sth->fetch) {print "@$row<br />";} 1;
The "table" consists of one record:
name|age|address|phone Sandra | 46 | 1252 Some St, Anywhere, WI 12345 | 123-456-7890
I was getting some wierd results and so went in and activated the debugging code left in place. Specifically, the code is located at line 529 in the open_table sub as follows:
print join("\n", $format,@$file,$createMode), "\n";
This would return the error -
DBD::AnyData::st execute failed: Can't use string ("databases/mothers.tbl") as an ARRAY ref while "strict refs" in use at DBD/AnyData.pm line 529, <GEN0> line 1.
So, I replaced the print and join statement with the following -
if (ref($file) eq 'ARRAY'){print join("\n", $format, @$file, $createMo +de), "\n";}<br /> else {print join("\n", $format, $file, $createMode), "\n";}
This then allows the printing of $file when it was not an array ref.
As I said, I hope that I have not wasted anyone's time with this. And btw, where is that stand alone version? My host does not have this pm or many of the supporting pms.
Humbly -
Ron Goral
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: DBD::Anydata
by jZed (Prior) on Nov 18, 2004 at 19:28 UTC |