http://www.perlmonks.org?node_id=1027256

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

Good day to all. This is a question about data persistence.

Context

A complex data structure, many hashes deep and many hashes wide, needs to be read from and written to. It needs to persist between program runs. I don't need to have more than a bit of it in memory at any time.

I found use MLDBM through http://www.perl.com/pub/2006/02/16/mldbm.html.

Pros: does all the above.

Cons: Need to extract a reference to work on and save it back to the file. EDIT: Con: can't edit references directly in the database file because references are no longer tied once extracted. This makes for clunkier code.

Questions

Is this good, bad, and/or ugly? Is this the state of the art? What are the different ways that monks have dealt with this kind of situation? Will I ever come to a decision? Am I forever doomed to to obsess about it? Tune in next week . . .

Thank you all. EDIT: spell check fail (persistance changed to persistence) (thank you erix)
$state{tired}?sleep(40):eat("crow");

Replies are listed 'Best First'.
Re: Persistent Data: my choice, and (hopefully) monks' thoughts.
by Anonymous Monk on Apr 06, 2013 at 07:44 UTC
      But why "Anonymous"? This is such a damned useful reply. I'm investigating DBM:: deep at the moment. Thank you.