in reply to Re: Populating hash keys and LDAP: putting things together
in thread Populating hash keys and LDAP: putting things together

Thanks. Now it is much more clear than before. I need to store a kind hierarchical menu, and values should be assigned to all nodes, not only to leaf nodes. That way, I need not only
$href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=1'}{'n=1'} = 'entry1111';
but also
$href->{'p=root'}{'cp=1'} = 'entry1'; $href->{'p=root'}{'cp=1'}{'n=1'} = 'entry11'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'} ='entry111';
What data structore can be used for this?

--dda

Replies are listed 'Best First'.
Re: Re: Re: Populating hash keys and LDAP: putting things together
by bart (Canon) on Oct 07, 2003 at 11:43 UTC
    Well... one thing you could do, is when your data has a specific format — and it looks like it does, judging by your example, that everything contains an "=" sign — is add a special hash key for your normal values. I'd propose a '$', reminescent of the string suffix in BASIC, or the scalar sigil in Perl if you like.
    $href->{'p=root'}{'cp=1'}{'$'} = 'entry1'; $href->{'p=root'}{'cp=1'}{'n=1'}{'$'} = 'entry11'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'$'} ='entry111'; $href->{'p=root'}{'cp=1'}{'n=1'}{'n=1'}{'n=1'}{'$'} ='entry1111';
    That should work well, without a conflict.

    If you need more kinds of (meta-)data, you can add more special keys.