Nitrox has asked for the wisdom of the Perl Monks concerning the following question:
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):
Here is the output from the first Data::Dumper call:#!/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__
Then a task is shift'ed off the array and a dump shows that we indeed have the first element:$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' );
But the second dump of the deep structure shows that the second element is missing:$VAR1 = \bless( { 'FILE' => 'bar1', 'CMD' => 'foo1' }, 'DBM::Deep' );
$VAR1 = \bless( { 'TASK_QUEUE' => bless( { 'DEV' => bless( [ bless( { 'FILE' => 'bar1', 'CMD' => 'foo1' }, 'DBM::Deep' ) ], 'DBM::Deep' ) }, 'DBM::Deep' ) }, 'DBM::Deep' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd behavior with DBM::Deep
by kvale (Monsignor) on Oct 21, 2004 at 00:38 UTC | |
by Nitrox (Chaplain) on Oct 21, 2004 at 00:48 UTC | |
by BrowserUk (Patriarch) on Oct 21, 2004 at 01:16 UTC | |
|
Re: Odd behavior with DBM::Deep
by Nitrox (Chaplain) on Oct 21, 2004 at 01:37 UTC | |
by Anonymous Monk on Oct 21, 2004 at 10:14 UTC |