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

Currently for my forums and message boards I use the DB_File module. However, DB_File is not compatible with associative hashes (hashes within hashes).

So currently, on my forums, I store a post something like this:

$forum{$timestamp} = "$author\t$subject\t$message";

Obviously, if I want to add a field like $email in between author and subject, I have to re-program every snippet of code that calls a post.

So I guess my question is: what kind of database should I use for forums? Ideally I would like to use the same kind of database for other projects like user management, chat rooms and advertisement delivery.

Thanks so much!

Replies are listed 'Best First'.
Re: best module for forum database?
by shmem (Chancellor) on Jun 26, 2006 at 00:01 UTC
    You might want to have a look at DBI. It contains drivers for various databases, the tinyest being SQLite. With DBI you store data with SQL statements.

    If you want to go on with DB_File, have a look at Storable. It serializes data structures which you can then store into a DB_File database file. Or have a look at MLDBM - it stores multi-level hash structure in a single level tied hash.

    Best is the one that fits your needs ;-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: best module for forum database?
by TedPride (Priest) on Jun 26, 2006 at 03:55 UTC
    Seems to me that the only reason you're storing items in a multi-level structure is so you can access posts by timestamp. This doesn't make a whole lot of sense. Use DBI and mySQL and a simple table format, and you may want to install one of the popular forums (phpBB, for instance) as well so you can get some ideas for how to arrange your tables and fields. The way you're currently doing things is a bit of a kludge.

    And to be honest, you're probably better off using existing forum software that's been fairly well optimized and bug checked, rather than spending months developing your own. I've been that route, and it isn't pretty.

      Thanks for the advice.

      We nearly always develop our own code, including forums, search engines, chat rooms, etc. We need to be able to customize our scripts.