Simple database in MacPerl
[email protected] ("Stephen Criddle") Wed, 17 Oct 2001 15:32:48 +0100
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <[email protected]> |
I've been trying to use DBM files (as documented in the O'Reilly Perl
Cookbook) using DB_File and the dbmopen command, then accessing the data
as a normal hash. I just can't seem to get this to work under MacPerl
(even though the lib files are there). MacPerl keeps locking up, or not
updating the has properly when I try to run even a simple program. For
instance:
#!perl
use DB_File;
$dbName = "testdb.db";
dbmopen %dbHASH, $dbName, 0666 or die "Can't open DB File";
$dbHASH{"Steve"}++;
print $dbHASH{"Steve"}."\n";
$dbHASH{"Steve"}++;
print $dbHASH{"Steve"}."\n";
dbmclose %dbHASH;
When I first run this, the testdb.db file is created successfully.
However, the output when the program is either:
1
1
or
1
<MacPerl locks up>
Am I doing something wrong here? (Trying to use DB_File, perhaps?) Or
is there a simple alternative for what I'm trying to do. I really don't
want to get bogged down in using SQL if I can help it, since all I'm
trying to do is create a lookup table based on a key value.
Since the file number of keys might get quite large (IP addresses on an
intranet), I wanted to use a hash rather than hunting through a text
file for the value I'm after).
Steve Criddle
This email and the files sent with it are confidential and for the use of the
intended recipient(s) only. If you are not the intended recipient(s), please
note that any use, distribution or copying of this communication or the
information in it, is strictly prohibited. If you have received this
communication in error, please notify the sender or forward this message to
[email protected] and then destroy the email and any copies of it. This
communication is from Saga Holidays Ltd whose registered office is The Saga
Building, Enbrook Park, Folkestone, UK CT20 3SE. Registered number 02174052.