hi, I'm tieing HoH, with the following structure :
$hash{keylvl1}{keylvl2}
The shortened code is below..
package Tie::HashDF; use strict; BEGIN { require Exporter; require Tie::Hash; @Tie::HashDF::ISA = qw(Exporter Tie::StdHash); @Tie::HashDF::EXPORT = qw(); } sub tolog { print "$_[0] : $_[1]\n"} sub TIEHASH { my $self = bless {}, shift; return $self } sub FETCH { tolog 'FETCH', "$_[1] : $_[0]{$_[1]}"; $_[0]{$_[1]} } sub STORE { tolog 'STORE'; } 1;
When I do this several assignments I get FETCHE's instead of STORE:
#!/usr/bin/perl use strict; use lib '/work/lib'; use Tie::HashDF; my $obj = tie my %hash, 'Tie::HashDF'; #my $a = $hash{toby}{ip}; $hash{toby}{ip} = '111'; $hash{drago}{account} = 'halo'; #undef $obj; #untie %hash;
-----
FETCH : toby : HASH(0x821a9a0) FETCH : drago : HASH(0x81433fc)
Could this be problem 'cause it is not onlevel-hash.. When I write this hash to disk all changes I have made are seen. i.e. it works as expected from me, but instead of triggering STORE it triggers FETCH..
I want to be sure when I'm doing STORE so that I do some checks there.
If I uncomment the line with assignment of hash element to variable I get another FETCH i.e.
FETCH : toby : HASH(0x821a9dc) FETCH : toby : HASH(0x821a9dc) FETCH : drago : HASH(0x8143520)
what I'm doing wrong ?

In reply to tieing HoH by bugsbunny

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.