Note that there are some explanatory texts on larger screens.

plurals
  1. POCan BerkeleyDB in perl handle a hash of hashes of hashes (up to n)?
    primarykey
    data
    text
    <p>I have a script that utilizes a hash, which contains four strings as keys whose values are hashes. These hashes also contain four strings as keys which also have hashes as their values. This pattern continues up to n-1 levels, which is determined at run-time. The nth-level of hashes contain integer (as opposed to the usual hash-reference) values. </p> <p>I installed the BerkeleyDB module for Perl so I can use disk space instead of RAM to store this hash. I assumed that I could simply tie the hash to a database, and it would work, so I added the following to my code: </p> <pre><code>my %tags = () ; my $file = "db_tags.db" ; unlink $file; tie %tags, "BerkeleyDB::Hash", -Filename =&gt; $file, -Flags =&gt; DB_CREATE or die "Cannot open $file\n" ; </code></pre> <p>However, I get the error:</p> <p>Can't use string ("HASH(0x1a69ad8)") as a HASH ref while "strict refs" in use at getUniqSubTreeBDB.pl line 31, line 1.</p> <p>To test, I created a new script, with the code (above) that tied to hash to a file. Then I added the following: </p> <pre><code>my $href = \%tags; $tags{'C'} = {} ; </code></pre> <p>And it ran fine. Then I added: </p> <pre><code>$tags{'C'}-&gt;{'G'} = {} ; </code></pre> <p>And it would give pretty much the same error. I am thinking that BerkeleyDB cannot handle the type of data structure I am creating. Maybe it was able to handle the first level (C->{}) in my test because it was just a regular key -> scaler? </p> <p>Anyways, any suggestions or affirmations of my hypothesis would be appreciated. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload