Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to save/restore a hash of hashes?

Reply
Thread Tools

How to save/restore a hash of hashes?

 
 
David Filmer
Guest
Posts: n/a
 
      11-09-2004
I want to be able to save the values of a hash of hashes (of hashes of
hashes, actually) to a textfile and be able to restore the hash (at a later
time) by reading the textfile.

If it were a simple hash, it would be trivial to save/reload the key/value
pairs. But a hash of hashes (of hashes of hashes) doesn't lend itself to
such a trivial solution. I could do a "brute force" approach, drilling down
to each value and saving it in an expected order (and restore it in a
brute-force approach in the same order) but that doesn't seem very elegant
(in fact, it's downright ghastly).

I would appreciate a suggestion as to how I might accomplish this in an
elegant fashion.

Thanks!


 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      11-09-2004
David Filmer <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> I want to be able to save the values of a hash of hashes (of hashes of
> hashes, actually) to a textfile and be able to restore the hash (at a later
> time) by reading the textfile.


Data:umper or Storable (standard modules). FreezeThaw from CPAN.

Anno
 
Reply With Quote
 
 
 
 
David Filmer
Guest
Posts: n/a
 
      11-09-2004
Awesome - thanks! A quick read-thru of Data:umper looks great but Storable
(and prehaps FreezeThaw - still figuring that one out) is incredible and
exactly what I need. I very much appreciate you pointing me in this
direction.

Cheers!

"Anno Siegel" <(E-Mail Removed)-berlin.de> wrote in message
news:cmq3sh$sf3$(E-Mail Removed)-Berlin.DE...
> Data:umper or Storable (standard modules). FreezeThaw from CPAN.
>
> Anno



 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      11-09-2004

Quoth "David Filmer" <(E-Mail Removed)>:
> "Anno Siegel" <(E-Mail Removed)-berlin.de> wrote in message
> news:cmq3sh$sf3$(E-Mail Removed)-Berlin.DE...
> > Data:umper or Storable (standard modules). FreezeThaw from CPAN.

>
> Awesome - thanks! A quick read-thru of Data:umper looks great but Storable
> (and prehaps FreezeThaw - still figuring that one out) is incredible and
> exactly what I need. I very much appreciate you pointing me in this
> direction.


The only disadvantage of Storable is that it produces binary, rather
than text, files. You did originally specify text, but may not have
meant it.

If you decide you *do* need text files, I would recommend Data:ump
from CPAN rather than Dumper, as I find it easier to use.

Ben

--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Eric Bohlman
Guest
Posts: n/a
 
      11-11-2004
Ben Morrow <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Quoth "David Filmer" <(E-Mail Removed)>:
>> "Anno Siegel" <(E-Mail Removed)-berlin.de> wrote in message
>> news:cmq3sh$sf3$(E-Mail Removed)-Berlin.DE...
>> > Data:umper or Storable (standard modules). FreezeThaw from CPAN.

>>
>> Awesome - thanks! A quick read-thru of Data:umper looks great but
>> Storable (and prehaps FreezeThaw - still figuring that one out) is
>> incredible and exactly what I need. I very much appreciate you
>> pointing me in this direction.

>
> The only disadvantage of Storable is that it produces binary, rather
> than text, files. You did originally specify text, but may not have
> meant it.
>
> If you decide you *do* need text files, I would recommend Data:ump
> from CPAN rather than Dumper, as I find it easier to use.


And take at least a glance at YAML.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
In 'HashMap.put', "if (e.hash == hash && eq(k, e.key))" ? Red Orchid Java 3 01-30-2006 07:04 PM
standard library for hash table storage and hash algorithm Pieter Claassen C Programming 1 08-04-2004 03:11 AM



Advertisments