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.
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:
my %tags = () ;
my $file = "db_tags.db" ;
unlink $file;
tie %tags, "BerkeleyDB::Hash",
-Filename => $file,
-Flags => DB_CREATE
or die "Cannot open $file\n" ;
However, I get the error:
Can't use string ("HASH(0x1a69ad8)") as a HASH ref while "strict refs" in use at getUniqSubTreeBDB.pl line 31, line 1.
To test, I created a new script, with the code (above) that tied to hash to a file. Then I added the following:
my $href = \%tags;
$tags{'C'} = {} ;
And it ran fine. Then I added:
$tags{'C'}->{'G'} = {} ;
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?
Anyways, any suggestions or affirmations of my hypothesis would be appreciated.