funduraghu has asked for the wisdom of the Perl Monks concerning the following question:

I'm using DBM::Deep to store data persistently.
The data contains hashes and object references.

Here is how I create a DBM::Deep object
$db = DBM::Deep->new(file => "foo.db", locking => 1, autoflush => 1);
I have large set of unprocessed log files and as I keep traversing each line in the log file, I keep adding object references to the $db object.

Here is how $db is arranged:
$db->{1111} = $bucketobj; $bucketobj->{urlindex} = [$url $url2] $bucketobj->{referrerindex} = [$url3 $url4]
After processing a substantial number of log lines, I now need to co-relate the information I have collected in the $db object.
During this processing, I need to delete some object references from the DBM object.
splice(@{$bucketobj->{referrerindex}, 1, 1)
This is when I encounter the error "DBM::Deep Can't store something that is tied"

Can someone help me out.

Thanks
funduraghu

Replies are listed 'Best First'.
Re: DBM::Deep Can't store something that is tied
by stvn (Monsignor) on Sep 06, 2007 at 13:30 UTC

    Nested tied structures will work in DBM::Deep pre-1.0. The author added transactional abilities, which required a heafty refactor and in the process this feature got "lost". When last I talked to the author (a couple months ago), he was too busy with $work to be able to address this. You might try giving him a poke and see where he is at with it.

    -stvn
      Kinda. You couldn't store something that was tied to anything but DBM::Deep.

      As for why this feature got "lost", it had to do with the fact that the feature was broken as implemented pre-1.0. When proper references get added, this'll be there.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: DBM::Deep Can't store something that is tied (Bug fixed)
by dragonchild (Archbishop) on Sep 21, 2007 at 02:15 UTC
    I just uploaded 1.0002 to CPAN which fixes this bug.
Re: DBM::Deep Can't store something that is tied
by DrHyde (Prior) on Sep 06, 2007 at 09:52 UTC
    Don't try to put anything into a DBM::Deep stucture that is tied, cos it won't work. The reason is that DBM::Deep uses tied structures itself, and you can only tie() to one class at a time in perl.
      I'm just trying to modify an array list (tied to DBM::Deep itself) and delete one of the entries.

      I also tried doing the following thing:
      $db->delete(1111); splice(splice(@{$bucketobj->{referrerindex}}, 1, 1); $db->{1111} = $bucketobj; # Modified object
      Even this doesn't work
      While technically true, this can be worked around quite easily in most cases. But, since my brain hasn't wanted to work through all the possibilities, I have taken the safe route and disallowed it in all cases. The biggest problem is things that are tied to external resources, like DBI.

      One of these days I'll add a facade that allows for storing tied things.


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: DBM::Deep Can't store something that is tied
by Anonymous Monk on Sep 06, 2007 at 09:01 UTC
    splice(@{$bucketobj->{referrerindex}, 1, 1) is typo, should be splice(@{$bucketobj->{referrerindex}}, 1, 1)
      Yes, thats a typo error.