Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Populating hash keys and LDAP: putting things together

by dda (Friar)
on Oct 07, 2003 at 11:17 UTC ( [id://297253]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://297253]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found