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

I've got a quick little AnyDBM_File database set up.
use Fcntl; use AnyDBM_File; tie %hash, 'AnyDBM_File', "test", O_RDWR|O_CREAT, 0664;
Is there any way to make this work with hashes of hashes?
$hash{value}{another_value} = 3;
Thanks

Replies are listed 'Best First'.
Re (tilly) 1: AnyDBM_File with Hashes of Hashes
by tilly (Archbishop) on Feb 07, 2001 at 06:33 UTC
    What merlyn said. Also a warning. AnyDBM_File is just a wrapper around other dbm solutions. Those solutions vary widely in quality, for instance the one that comes with Perl (SDBM_File) cannot handle arbitrary amounts of data. Therefore code that may work on one machine may not on another.

    Even worse, the actual dbm files created have a binary format that depends upon what is installed locally. They will not be portable from machine to machine, and if you install a better package (eg DB_File) you may suddenly find yourself incompatible with your own data.

    So for any production use I would steer you away from AnyDBM_File and towards a known good solution like DB_File.

Re: AnyDBM_File with Hashes of Hashes
by merlyn (Sage) on Feb 07, 2001 at 06:15 UTC
    Not directly. You can get some nested-data-structure support using MLDBM, although unless you know what it's doing precisely, you can lose data, and once you know what it's doing, you can simply call one of the real marshallers at the right time instead. {grin}

    -- Randal L. Schwartz, Perl hacker