Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Storable to Data::Dumper again

by Anonymous Monk
on Jan 09, 2003 at 09:14 UTC ( #225490=perlquestion: print w/replies, xml ) Need Help??

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

Hi monks I have some doubts regarding storable.
This piece of code is from manpage of MLDBM.
I dont seem to understand how to store the hash
Any suggestions? Basically i would like to store a file as storable(MLDBM)
retrieve it and then do some changes and then store it back
using Data::Dumper(MLDBM).
Thanks a lot
Yet to be monk
use MLDBM qw(DB_File Storable); tie %o, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640 or die $!; (tied %o)->DumpMeth('portable'); $o{'ENV'} = \%ENV;

Replies are listed 'Best First'.
Re: Storable to Data::Dumper again
by ph0enix (Friar) on Jan 09, 2003 at 11:33 UTC

    Hash to be stored must be converted into scalar. This conversion is done by Storable::nfreeze. The MLDBM module does this conversion for you silently and store this linearized value to DBM file you specify using proper module (DB_File is used in your example).

    In your example the %o hash is stored in testmldbm file which is BerkeleyDB database file. Not less and not more. Also please read BUGS and WARNINGS section in MLDBM documentation to know about problems with nested structures modification.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://225490]
Approved by mce
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2023-09-30 03:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found