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

Hello monks
I basically am using MLDBM with data::dumper,
to store some data in the disc.
Now i would like to retrieve the whole hash
and load it to the memory for further use
How do i load the whole hash on to memory.
Thanks in advance
I

Replies are listed 'Best First'.
Re: MLDBM
by pg (Canon) on Nov 15, 2002 at 04:51 UTC
    MLDBM actually ISA TieHash, and implements the interface. At the time, you serialized the data structure into MLDBM file, you did a tie. When you read it back, do the same tie again, without specifying O_CREATE. The content of your MLDBM file will be fetched into the Tied Hash (this is transparent to you), now you can used the tied hash, and it supports all the stanbard methods you can apply on a hash.
      do something like this: (Assume you have a hash that has two pairs: "a" => 1, and "b" => 2. You can have a much much more complex structure than this sample)
      use Fcntl; #so perl understand what is O_RDONLY use MLDBM; tie %hash, 'MLDBM', 'file', O_RDONLY, 0666; print $hash{"a"}; print $hash{"b"};


      it would print 12.
Re: MLDBM
by jjdraco (Scribe) on Nov 15, 2002 at 03:01 UTC
    Not really sure what you are trying to do here but have you looked at the MLDBM module on CPAN

    jjdraco
    learning Perl one statement at a time.