Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Storable to Data::Dumper again

by Anonymous Monk
on Jan 09, 2003 at 09:14 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-29 02:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found