in reply to Pattern-matching hash keys

In the conditional of lines 24-26, and again in 28-30, you're testing for the presence of a hash key, then populating that level as an array. Your Dumper output confirms that the array treatment wins. You don't push onto a hash, you assign. Since you have an array, the hash key never exists and each $policy seen goes into the array, duplicate or not.

Aside from that, I'm unsure what you're asking.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Pattern-matching hash keys
by blink (Scribe) on Sep 20, 2003 at 20:44 UTC
    Thanks for your reply! I'm sorry, I wasn't as clear as I could have been
    if ( ! exists ( $status{$client}{'policy'}{$policy} )) { push @{$status{$client}{'policy'}} , $policy ; }
    I'm building a Hash of Hashes of Arrays. In this example, %status is a hash, whose keys are also hashes named $client. Each key "$client" is a hash of arrays. In the above example, there is one key (array) named "policy". "policy" should contain a list of, well, policies.

    Ultimately, I'm trying to create something like:

    %STATUS { Client1, Policy, [ policy1, policy2, policy3 ] ID [ id1, id2, id3 ] }