|There's more than one way to do things|
DB_File recno treats array like a hashby vleschuk (Initiate)
|on Oct 12, 2012 at 05:41 UTC||Need Help??|
vleschuk has asked for the
wisdom of the Perl Monks concerning the following question:
I have faced rather strange issue when working with DB_File module.
Please see the two sample scripts below:
. The situation is the following:
- writedb.pl script creates a DB file tied to perl array (not hash) with fixed length records.
- than it puts there two records
- after that readdb.pl opens test.db file with the same parameters as writedb.pl and ties it also to an array
- readdb.pl reports the number of records existing in queue
This works fine on debian linux amd64 (perl 5.14.2). But fails on NetBSD amd64 (perl 5.14.2 too), OpenBSD amd64 (perl 5.12.2), FreeBSD amd64 (perl 5.12.4). On *BSDs it reports doubled DB size, for scripts attached it should be 2, but readdb.pl reports 4. I checked it under debugger and it seems that perl treats DB as tied to hash, not array (e.g. array with pairs of key and value). It creates array of doubled size, where each first value is data from file and each second value is empty.
Could you please advise whether I am doing anything wrong (maybe I am missing some important parameters) or it is bug in BSD implementation.
Thanks in advance.