in reply to Re: Need help with complex tied data structure
in thread Need help with complex tied data structure

Yes, I saw that. That's why I show the code at the end of my question with the $tmp variable. I tried pointing $tmp to different depths in the data structure, as well as having multiple temporary variables like:
$tmp = $data[$gid]; $tmp2 = $tmp->{$id}; $tmp2->[$element_num] = $element;
But none of that seemed to work.

Replies are listed 'Best First'.
Re: Need help with complex tied data structure
by Abigail-II (Bishop) on Nov 20, 2003 at 23:34 UTC
    The fragment I posted also stresses out the importance of storing back the modified value in the top level hash. Your code doesn't do that.

    Abigail

      I see your point. So, then I should do this:
      $tmp = $data[$gid]->{$id}; $tmp->[$element_num] = $element; $data[$gid]->{$id} = $tmp;
      I haven't tested this yet, but while typing it, I noticed that with the $tmp assignment, that I'm pulling all of @{$data[$gid]->{$id}} into memory, partly obviating the advantage of the disk-based tie. It would make more sense then to generate the entire @{$data[$gid]->{$id}} array in memory and only save it when all the elements are computed. Is that correct?