What I need is to create the following hash:Uh-uh. You can't have both. You see, if your create the latter first, then $href->{'p=root'{'cp=1'} will be a hash ref. And if you'd try to create them in the order above, you'll end up using 'entry1' as a symbolic reference for a hash %entry1, thus setting $entry1{'n=1'} = 'entry11';.$href->{p=root}{cp=1} = 'entry1' $href->{p=root}{cp=1}{n=1} = 'entry11'
With the data you've given, the only thing you can populate, is the following structure — even though I don't understand the structure of your values:
Resulting in:$href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=1'}{'n=1'} = 'entry1111'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=1'}{'n=2'} = 'entry1112'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=1'}{'n=3'} = 'entry1113'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=2'}{'n=1'} = 'entry1121'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=2'}{'n=2'} = 'entry1122'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=2'}{'n=3'} = 'entry1123'; # Let's see what we got: use Data::Dumper; $Data::Dumper::Indent = 1; print Dumper $href;
That's it. You can't put anything more in it. Not like his. You might have to find another data structure type to hold your data. Or you might have to reduce the amount of data you want to hold.$VAR1 = { 'p=root' => { 'cp=1' => { 'n=1' => { 'n=1' => { 'n=1' => { 'n=1' => 'entry1111', 'n=2' => 'entry1112', 'n=3' => 'entry1113' }, 'n=2' => { 'n=1' => 'entry1121', 'n=2' => 'entry1122', 'n=3' => 'entry1123' } } } } } };
In reply to Re: Populating hash keys and LDAP: putting things together
by bart
in thread Populating hash keys and LDAP: putting things together
by dda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |