I wish to push multiple values into a tie'd hash of the DB_File verity. For memory-based hashes, my toilings seem to work. However, the following chokes:
#!/usr/pkg/bin/perl -w unlink("revmap_check_deleteme"); $myhashinfo=new DB_File::HASHINFO; $myhashinfo->{bsize}=8192; # The amount of data I intend to store is quite large. I # had to increase the bsize as a result.. tie(%revmap, "DB_File", "revmap_check_deleteme", O_CREAT|O_RDWR, 0666, + $myhashinfo) or die "Unable to create database tie.\n"; # So here we create duplicate values for every item in # the memory hash. for ($counter=0; $counter<10; $counter++) { push @{$memrevmap{$counter}}, "somefile$counter"; push @{$memrevmap{$counter}}, "somefile$counter"; } # Now, here's my (lame) attempt to copy the normal hash to # the tie'd disk hash. foreach $key (keys %memrevmap) { foreach $val (@{$memrevmap{$key}}) { print "pushing into $key, $val\n"; @{$revmap{$key}}=(@{$revmap{$key}}, $val); } } # And here's my attempt to verify that the values were # in fact written to disk. If I change the item below to # memrevmap, it works. foreach $key (keys %revmap) { print "key = $key\n"; print "Data values: "; foreach $val (@{$revmap{$key}}) { print "subval: $val\n"; } } untie %revmap; print "Done.";
How should I better stuff, to-disk, the complete hash I built? Thank you.

In reply to pushing into a tie'd hash by mast

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.