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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.