I am using perl DB_File module to persist the hash variable into a file.
My hash variable contains key as normal string and value as another hash variable.
I used Storable::freeze(\%value);
to serialize the hash value.
But when I tried to retrieve the values, I got an error. For the first time when I run the retrieve code, it works. The next consecutive times, it fails.
I used method like this:
tie(%HASH, "DB_File", "dbfile", O_RDWR, 0444);
foreach $key (%HASH)
{
$hashRef = Storable::thaw($HASH{$key}; --> here it fails with the error
}
Error message
Storable binary image v25.47 more recent than I am (v2.7) at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/thaw.al) line 366, at retrieve.pl line 15 at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/logcroak.al) line 74 Storable::logcroak('') called at ../../lib/Storable.pm (autosplit into ../../lib/auto/Storable/thaw.al) line 367 Storable::thaw('2/8') called at retrieve.pl line 15
Have a look at the error:
The value that you are trying to thaw is the scalar result of a hash.
I assume that the
$HASH{$key}
incontains a hash (may be of frozen objects).
Try to add
before you try to thaw the value, to see its content.