Tim Musson wrote:
> 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" };

Write as:

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

or:

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

or even (assign to hash slice):

  @{$hash{four}}{qw/uid cn group/} = ('uid4', 'cn4', 'Group4');

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

Reply via email to