Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Need help with filling a complicated data structure

by Laurent_R (Canon)
on Nov 16, 2013 at 11:05 UTC ( [id://1062878]=note: print w/replies, xml ) Need Help??


in reply to Need help with filling a complicated data structure

Hi Lady_Aleena

I am wondering about something: if I understand correctly, your input data has a hierarchy with only 3 levels, and from there, you seem to be willing to build a nested structure with about nine levels of "nestedness". Are you sure you really need such a complicated data structure? It seems to be overkill to me. Wouldn't a simple 3-level nested data structure be more practical?

Cheers

  • Comment on Re: Need help with filling a complicated data structure

Replies are listed 'Best First'.
Re^2: Need help with filling a complicated data structure
by Lady_Aleena (Priest) on Nov 16, 2013 at 13:22 UTC

    Laurent_R, for 1 level it is rather easy to use list.

    list($tab, $type, [$value1, $value2]);

    Now if either of those have a list too, it starts to get complicated.

    list($tab, $type, [ [$value1, { inlist => [ $inlist1_type, [ $value1a, $value1b ] ], cla +ss => $value1class }], [$value2, { inlist => [ $inlist2_type, [ $value2a, $value2b ] ]}], ]);

    And if it goes deeper.

    list($tab, $type, [ [$value1, { inlist => [ $inlist1_type, [ $value1a, $value1b ] ], cla +ss => $value1class }], [$value2, { inlist => [ $inlist2_type, [ [$value2a, { inlist => [ $inlist2a_type, [$value2a1, $value2a2 ] ] +}], [$value2b, { style => 'font-size: small' }] ]]}], ]);

    A lot more than the inner lists goes into the hash refs: class, id, style, lang, various javascript attributes. For list items there is also value, so if $value2's inlist were an ordered list (but not starting at 1), I would do the following, and will have to for some lists...

    list($tab, $type, [ [$value1, { inlist => [ $inlist1_type, [ $value1a, $value1b ] ], cla +ss => $value1class }], [$value2, { inlist => [ $inlist2_type, [ [$value2a, { inlist => [ 'o', [ [$value2a1, { value => '2' }], $value2a2 ]]}], [$value2b, { style => 'font-size: small' }] ]]}], ]);

    For example, I own books 2-5 of Bio of a Space Tyrant by Piers Anthony, so I would like to write the data like...

    #2 Mercenary # Politican # Executive # Statesman

    For for another series of novels, it is even odder.

    #41 The Soldier's of Fear #47 Q-Space

    Writing the subroutines to make HTML lists was kind of fun, but it is a lot of work to use it.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found