in reply to Re: hash of hash - incorrect values?
in thread hash of hash - incorrect values?

I guess that's part of my question. Can a lower level of a hash contain a value and also be linked to other levels of hashes? I thought they could, but maybe not?

If they can't, than I don't understand how I am obtaining values at all, both for the incremented integer and also for the key and the related value in the deeply nested structure.

comments?

Replies are listed 'Best First'.
Re^3: hash of hash - incorrect values?
by ikegami (Patriarch) on Aug 03, 2005 at 19:40 UTC

    You misunderstand $hash{a}{b}. Hashes only have one level. $hash{a}{b} is a hash of a hash. $hash{a}{b} is a shortcut for ${$hash{a}}{b}. That means "the value at key 'b' in the hash referenced by $hash{a}." $hash{a} can't contain both a hash reference and a number, so $hash{a}++ and $hash{a}{b} conflict.

    There is an easy solution. Replace

    $Stats{$DestPort}++; $Stats{$DestPort}{covert}{"..."}++;

    with

    $Stats{$DestPort}{total}++; $Stats{$DestPort}{covert}{"..."}++;

    or

    $Stats{$DestPort}{total}++; $Stats{$DestPort}{item}{covert}{"..."}++;
Re^3: hash of hash - incorrect values?
by VSarkiss (Monsignor) on Aug 03, 2005 at 19:42 UTC