Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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):

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?


Swiss Army Nerd

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

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (5)
    As of 2018-01-18 12:13 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (211 votes). Check out past polls.