Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

OK, Monks, I have more of a conceptual question this time. I have a whole mess of data in a big ol' nested HoHoH (and the occasional array, too). Format like what's below:

%cmdData = ( 'command_1' => { 'subfields' => [], 'description' => 'descriptive text', 'safety' => 'SAFE', 'opcode' => 'code_1' }, 'command_2' => { 'subfields' => [ { '_size' => 32, 'state_conversions' => [], 'subfield_name' => 'sub_1', '_fsw_type' => 'UINT32', }, { '_size' => 32, 'state_conversions' => [], 'subfield_name' => 'sub_2', '_fsw_type' => 'UINT32', }, ], 'description' => 'descriptive text', 'safety' => 'SAFE', 'opcode' => 'code_2' } 'command_3' => { 'subfields' => [ { '_size' => 16, 'state_conversions' => [], 'subfield_name' => 'sub_3', '_fsw_type' => 'UINT16', }, { '_size' => 32, 'state_conversions' => [], 'subfield_name' => 'sub_4', '_fsw_type' => 'UINT32', }, { '_size' => 8, 'state_conversions' => [], 'subfield_name' => 'sub_4', '_fsw_type' => 'UINT8', }, ], 'description' => 'descriptive text', 'safety' => 'SAFE', 'opcode' => 'code_3' } )

I have some code that, right now, goes through this data and, for each command, comes up with an HTML table like this (example for command 3 in the data above):
opcodesubfield(s)
code_1sub_1sub_2sub_3

99% of the time, this is fine. But there's a couple of commands that have a LOT of subfields - like 20 of them - and that just doesn't fit well.

What I am trying to determine is if there's a relatively easy way to break the big ones down into multiple tables. Like put the first 5 subfields in the first table, cut it off, then put the next 5 into another table, and so on. If this is going to be a PITA, or just take forever to code up, then I have my boss' OK to ignore the problem - we're talking about < 5 commands out of close to 300 that this applies to.

The existing code just uses a foreach to iterate through (and sort) the commands, an if/else to check for the existence of subfields, and if there are subfields, a for to iterate through those.

So, what do you guys think? Any brilliant insights? Should I leave the sleeping puppies alone, or can you think of a simple/quick way to handle this?

Thanks!

Kaiti
Swiss Army Nerd

In reply to How to approach this problem, or should I ignore it? by jedikaiti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (14)
    As of 2014-07-10 22:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (217 votes), past polls