Monks,

I'm trying to use MLDBM::Easy so I can update a value in a HoA without having to use a temporary variable, but the value is not updated. The perldoc for MLDBM::Easy says:

This module allows you to work with multi-dimensional databases, just like MLDBM, but it does work behind the scenes to allow you to treat the multi-dimensional database like a normal data structure. Basically, you don't need to use the piecemeal access that MLDBM required:

# old and busted my $record = $db{some_key}; $record->[2] += 100; $db{some_key} = $record; # new hotness $db{some_key}[2] += 100;
The following things do work making me think my data structure is ok: Here's my simple example:
#!/usr/bin/perl use strict; use warnings; use MLDBM::Easy; use Fcntl; my %hash; tie (%hash, 'MLDBM', 'testmldbm', O_CREAT|O_RDWR, 0640) or die $!; $hash{value1} = [ '0', '1', '2' ]; # assign anonymous array print "@{$hash{value1}}[0, 1, 2]\n"; $hash{value1}[2] += '1'; # add/modify element 2 untie %hash; tie (%hash, 'MLDBM', 'testmldbm', O_RDWR, 0640) or die $!; print "@{$hash{'value1'}}[0, 1, 2]\n"; untie %hash;

Which yields the following output:

0 1 2
0 1 2

It seems like I must be doing something wrong!? Any suggestions?

Thank-you.


In reply to MLDBM::Easy does not update data structure by gctaylor1

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.