beginners,

  I am trying to build a hash of hash references. My problem is that I
  need to be able to add a key/value pair to the internal hashes...

,----- [ Here is my test code (yes, I am working with LDAP) ]
#!perl
use strict;
use warnings;

my %hash = (
    one   => { uid => "uid1", cn => "cn1", group => "Group1" },
    two   => { uid => "uid2", cn => "cn2", group => "Group2" },
);
$hash{"three"} = { uid => "uid3", cn => "cn3", group => "Group3" };

$hash{"four"} = { uid => "uid4" };
$hash{"four"} = { cn => "cn4" };
$hash{"four"} = { group => "Group4" };

my $key;
foreach $key (sort keys %hash) {
         my $iHash = $hash{$key};
        print "
             key: $key
       hash-HRef: $hash{$key}
            HRef: $iHash
  hash/hash{uid}: $iHash->{uid}
   hash/hash{cn}: $iHash->{cn}
hash/hash{group}: $iHash->{group}
";
}
`----- [ End of my test code ]

So, I add the keys "one" and "two" when I initialize the hash, then I
add "three" after. That works just fine, but I need to do something like
"four", and all I get in the output is "Group4" because the third time I
write the anon reference to the hash, it overwrites of course...

Any suggestions on how I can do this? I don't think I can really use an
array, and push to it because of how we plan to access the top level
hash.

Background, I am doing an LDAP query for a couple of attributes in one
DN, then another LDAP query in a different part of the LDAP tree for
some other attributes.  The output for each query needs to be grouped by
something like UID (I will replace "one", "two", etc with the UID/CN
value as I extract it).  Yes, it is a messed up LDAP structure, but I
can't do anything about that... :-(

Thanks for any help!

-- 
Tim Musson
Flying with The Bat! eMail v1.62q
Windows 2000 5.0.2195 (Service Pack 3)
Contrary to popular belief, Unix is user friendly. It just happens to be
selective about who it makes friends with


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to