jedikaiti has asked for the wisdom of the Perl Monks concerning the following question:
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):
opcode | subfield(s) | ||
code_1 | sub_1 | sub_2 | sub_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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to approach this problem, or should I ignore it?
by jethro (Monsignor) on Apr 07, 2010 at 17:54 UTC | |
by jedikaiti (Hermit) on Apr 08, 2010 at 16:05 UTC | |
Re: How to approach this problem, or should I ignore it?
by rubasov (Friar) on Apr 07, 2010 at 21:04 UTC | |
by jedikaiti (Hermit) on Apr 08, 2010 at 16:20 UTC | |
How to approach these titles ...
by LanX (Saint) on Apr 07, 2010 at 17:57 UTC | |
by Argel (Prior) on Apr 07, 2010 at 20:43 UTC | |
by LanX (Saint) on Apr 07, 2010 at 20:56 UTC |