Re: database troubles
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 10 Aug 2006 08:43:15 -0700
hOURS wrote:
I want to use PERL
Perl is the language.
perl is the interpreter.
PERL is a misspelling of one of the above.
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.
No, that warning is not an indication that your DB never opened. It's
an indication that you're using an uninitialized variable. @A is not
the same as %A. If you had used strict, Perl would have told you that
you can't use @A without declaring it.
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.
The documentation for dbmopen says:
perldoc -f dbmopen
This binds a dbm(3), ndbm(3), sdbm(3), gdbm(3), or
Berkeley DB file to a hash. HASH is the name of the
hash. (Unlike normal "open", the first argument is
not a filehandle, even though it looks like one).
DBNAME is the name of the database (without the .dir
or .pag extension if any). If the database does not
exist, it is created with protection specified by
MASK (as modified by the "umask").
So I'd guess it's likely that it can't find the file you're asking
about. If the file doesn't exist in the current working directory, I
would suggest you do put the full path in the open statement.
My guess is that PERL doesn't handle the types of databases I have.
Perl handles just about every database type imaginable, through the DBI
module and various DBD::* modules. dbmopen() is pretty well
depreciated
I have databases with the extensions .wdb, .dbf, and .mdb.
I have no idea what those are. Are those dbm, ndbm, sdbm, or Berkely
DB files?
Am I on the right track? What's going on here?
Don't really know. The first step would be to find out what kind of
databases you actually have, and then look for a module on CPAN
(http://search.cpan.org) that deals with those kinds of databases. The
second step would be to always `use strict;` and `use warnings;` in
your code.
Paul Lalli
.
- References:
- database troubles
- From: hOURS
- database troubles
- Prev by Date: database troubles
- Next by Date: Re: Multiple matching question
- Previous by thread: database troubles
- Next by thread: RE: database troubles
- Index(es):
Relevant Pages
|