I've been familiarizing myself with DBM::Deep(v0.94) the last couple of days and have run into some weird behavior. I've read the documentation numerous times and don't see any errors, but again, I'm new to this module and wouldn't be surprised if it's something I'm doing wrong (seeing as the module has been around a couple of years).

The anomaly occurs when I shift an element off a "deep" array. I'm returned the first element as expected but when inspecting the structure after the shift, the first element is still in the array but what was the second element is missing.

Does anyone see where I'm going wrong or is this indeed a bug that should be reported to the author?

Here's a code stub that recreates the issue on my system (ActiveState v5.8.4 on WinXP):

#!/usr/bin/perl -w use strict; use DBM::Deep; use Data::Dumper; my $DBM = DBM::Deep->new("deep.db") or die("Couldn't initialize DB"); $DBM->clear(); $DBM->optimize(); $DBM->{TASK_QUEUE} = {}; $DBM->{TASK_QUEUE}->{DEV} = []; $DBM->{TASK_QUEUE}->{DEV}->push({CMD => "foo1", FILE => "bar1"}); $DBM->{TASK_QUEUE}->{DEV}->push({CMD => "foo2", FILE => "bar2"}); print Dumper(\$DBM); my $task = $DBM->{TASK_QUEUE}->{DEV}->shift(); print Dumper(\$task); print Dumper(\$DBM); __END__
Here is the output from the first Data::Dumper call:
$VAR1 = \bless( { 'TASK_QUEUE' => bless( { 'DEV' => bless( [ bless( { 'FILE' => 'bar1', 'CMD' => 'foo1' }, 'DBM::Deep' ), bless( { 'FILE' => 'bar2', 'CMD' => 'foo2' }, 'DBM::Deep' ) ], 'DBM::Deep' ) }, 'DBM::Deep' ) }, 'DBM::Deep' );
Then a task is shift'ed off the array and a dump shows that we indeed have the first element:
$VAR1 = \bless( { 'FILE' => 'bar1', 'CMD' => 'foo1' }, 'DBM::Deep' );
But the second dump of the deep structure shows that the second element is missing:
$VAR1 = \bless( { 'TASK_QUEUE' => bless( { 'DEV' => bless( [ bless( { 'FILE' => 'bar1', 'CMD' => 'foo1' }, 'DBM::Deep' ) ], 'DBM::Deep' ) }, 'DBM::Deep' ) }, 'DBM::Deep' );

In reply to Odd behavior with DBM::Deep by Nitrox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.