On 8/10/06, hOURS <[EMAIL PROTECTED]> wrote:
Hi,
I'm new to the list. Thanks everyone for having/doing this.
I want to use PERL to work with a database, but I can't seem to get PERL to open the
databases on my computer. I've been learning from Paul Hoffman's PERL for Dummies (3rd
edition). If I understand the book correctly, the code below should open my database
into an associative array, which I could then manipulate. e.g. In the program below I
try to print out the keys, print out an individual item, and change an individual item.
None of those 3 things happen though. The program also doesn't die, nor do I get an
error message. One thing it does execute for sure is the last line - printing out a
zero. That and the fact that when I "-w" the program it tells me I'm using an
uninitialized value in line 7 seem to indicate that the database simply never opens.
Why not?
By the way, I've tried various formulations of the second part of the
argument to dbmopen: with and without quotes, with and without file
extensions, having just the file name vs. specifying the whole path (like
C:/My Documents). Nothing works. But every time I run it, the computer
creates two files. Their names are the file name I put in the argument to
dbmopen, plus .dir for one, and .pag for the other.
My guess is that PERL doesn't handle the types of databases I have. I have
databases with the extensions .wdb, .dbf, and .mdb. Am I on the right track?
What's going on here?
Thank you very much,
Fred Kittelmann
%A = ();
dbmopen(%A, "hOURSexperim.dbf", 0600) or die "Not gonna open it.\n";
@AllKeys = keys(%A);
foreach $TheKey (@AllKeys)
{print "$TheKey is the key for $A{$TheKey}\n"}
$A[0][1] = "red";
print $A[5][0];
print scalar(%A);
Fred,
It all depends on the types of databases. dbmopen() works with
file-based databases like SDBM, NDBM, GDB and BDB.
To access relational (SQL) databases, like those created by MS Access,
MSSQL, MySQL, Postgres, Ingress, Oracle, dbase, etc., you need to use
the appropriate combination of DBI and DBD::yourdatabase modules.
Acess files should be available via DBD::ODBC. The CodeBase module
seems like a good alternative for xbase .dbf files. I'm not sure what
.wdb files are, but search cpan for something appropriate.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org
values of β will give rise to dom!