in reply to RE: Re: Any_DBM_File blues.
in thread Any_DBM_File blues.

Well, I don't have the DBI book, but that code sample that you say is from the book doesn't work for me.

So it looks like, since you don't have those other DBM packages, you must be using SDBM_File, since it's guaranteed to be there (it comes w/ Perl, according to the AnyDBM_File manpage).

So with that in mind, I was able to get this to work correctly, using SDBM_File. Add this line near the top of your file:

use Fcntl;
to import the file creation/read-write flags; and modify your tie line to look like this:
tie %database, 'AnyDBM_File', "bar", O_RDWR|O_CREAT, 0666 or die "doh + $!\n";
Which, if you look at the SDBM_File docs, matches up with what the tie line should look like. This works for me.

BTW, $DB_HASH, in the context of DB_File, is a special constant telling DB_File to use its DB_HASH package. It's the default for DB_File.

Replies are listed 'Best First'.
RE: RE: RE: Re: Any_DBM_File blues.
by skazat (Chaplain) on May 02, 2000 at 20:08 UTC
    wow thanks alot, that worked perfectly. i never used the AnyDBM_File module before, i always used the DB_File module, all the examples in the perl cookbook use the DB_File module and its almost guarenteed to come with a BSD system (like i'm on)

    once again, thanks!

    cheers,
    -justin