So I considered using tie and related functions to store the hash on disk. Of course, you can't have two dimensional hashes via tie. But since my first key is sparse (around 20 entries), I thought I could create a tied hash just for that key, so that the subkey would be on disk.
with the invocation of:sub checkdbm { my $hashref=shift; my $key=shift; if (-f "$key-dbm.db") { return; } tie (%{$hashref->{$key}},'NDBM_File',"$key-dbm",O_RDWR|O_CREAT,0640) +; }
But alas, I can't get it to work. The code executes, the key-dbm.db files are created, but no data is ever stored in it; the program grows in memory until even switching virtual consoles takes minutes to perform.checkdbm \%terms,$db; for my $t (@terms) { $terms{$db}{$t}++; }
Can anyone see what my problem is? (Ahem, my *programming* problem). I suspect I don't understand precisely how tie works and that is biting me in my butt.
TIA!
In reply to Tie, DBM's, HoH and Sparse Keys by mr.nick
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |