Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-28 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found