http://www.perlmonks.org?node_id=325190

pme has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, I'd like to use the indexed (dbm) files from both Perl and C. The file is generated from Perl and read by program written in C. I'm totally confused by the file formats (ndbm, gdbm, Berkeley DB etc.). What format should I use? On Debian 3.0r2 there is man page for dbopen, but the db.h contains the db_create() only. I'd like to avoid installing new libraraies. Thanks in advance

Replies are listed 'Best First'.
Re: using indexed (dbm) files
by DrHyde (Prior) on Jan 30, 2004 at 12:23 UTC
    There's a nice feature comparison table here.
      Thanks, I've bookmarked it!
Re: using indexed (dbm) files
by RandomWalk (Beadle) on Jan 30, 2004 at 16:45 UTC
    From "Learning Perl": you might also check your AnyDBM_file manpage and/or you might want to download the "which_dbm" utility from

    http://examples.oreilly.com/lperl/3rd_edition_examples/

    The latter diagnoses which db you've already got.

      Thanks, I'll try it.
Re: using indexed (dbm) files
by scottj (Monk) on Jan 31, 2004 at 10:13 UTC
    I have done this in the past with Berkeley DB and had much success.

    I had a CGI written in C (way back in the day) that would write to the Berkeley DB. Then my perl script would come along every so often and yank the data out of the Berkeley DB for processing.

    I don't have a lot of experience with the other options you listed, but Berkeley DB is a very robust system that will probably handle just about anything you need it for. And the folks at Sleepycat are great, too. :)
Re: using indexed (dbm) files
by Anonymous Monk on Jan 30, 2004 at 23:40 UTC
    remember that C requires null terminated strings while perl does not.
Re: using indexed (dbm) files
by astroboy (Chaplain) on Feb 02, 2004 at 12:41 UTC
    Came across this site a couple of weeks ago. They do a pretty good job of looking at the various DBMS's and supply sample code, etc
A reply falls below the community's threshold of quality. You may see it by logging in.