.... there is also Storable.... ..... you might want to consider thread safety in whatever module you select......just in case you decide to use threads to speed up processing

check out this for example.... the first script creates the hash file, the second retreives it from file

#!/usr/bin/perl # the storer use strict; use warnings; use Data::Dumper; use Storable; my (%kids_of_wife, $man, $wife); $kids_of_wife{"Jacob"} = { "Leah" => ["Reuben", "Simeon", "Levi", "Judah", "Issachar", "Zebulun +"], "Rachel" => ["Joseph", "Benjamin"], "Bilhah" => ["Dan", "Naphtali"], "Zilpah" => ["Gad", "Asher"], }; $kids_of_wife{"Bill"} = { "Betty" => ["Bob", "Willy", "Fred", "Bilbo", "Frodo", "Dimwitia"], "Joan" => ["Mike", "Ben"], "Harriet" => ["Danny", "Hondo"], "Mary" => ["Marion", "Egad", "Clancy"], }; store(\%kids_of_wife,"zzwifehash"); print '################################################',"\n"; foreach (keys %kids_of_wife) { print $_,"\n"; } print '################################################',"\n"; foreach (keys %kids_of_wife) { print foreach (keys %{$kids_of_wife{$_}}),"\n"; } print '################################################',"\n"; foreach (keys %kids_of_wife) { my $man = $_; foreach (keys %{$kids_of_wife{$man}}){; print $_,"\n"; my $wife = $_; print @{$kids_of_wife{$man}{$wife}},"\n"; }} print '################################################',"\n"; foreach (keys %kids_of_wife) { $man = $_; foreach (keys %{$kids_of_wife{$man}}){; $wife = $_; print "$man + $wife = "; print "@{$kids_of_wife{$man}{$wife}}\n"; }} print '################################################',"\n"; #print Dumper(%kids_of_wife);
and a retreive example
#!/usr/bin/perl # the retreiver use strict; use warnings; use Data::Dumper; use Storable; my (%kids_of_wife,$man,$wife); #$href = retrieve("zzwifehash"); # by ref %kids_of_wife = %{retrieve('zzwifehash')}; # direct to hash print '################################################',"\n"; foreach (keys %kids_of_wife) { print $_,"\n"; } print '################################################',"\n"; foreach (keys %kids_of_wife) { print foreach (keys %{$kids_of_wife{$_}}),"\n"; } print '################################################',"\n"; foreach (keys %kids_of_wife) { my $man = $_; foreach (keys %{$kids_of_wife{$man}}){; print $_,"\n"; my $wife = $_; print @{$kids_of_wife{$man}{$wife}},"\n"; }} print '################################################',"\n"; foreach (keys %kids_of_wife) { $man = $_; foreach (keys %{$kids_of_wife{$man}}){; $wife = $_; print "$man + $wife = "; print "@{$kids_of_wife{$man}{$wife}}\n"; }} print '################################################',"\n"; #print Dumper(%kids_of_wife);

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku

In reply to Re: Tie Hash by zentara
in thread Tie Hash by BioLion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.