Hi Monks, Ok, so I have a table of mapped IDs. It contains 3 fields: project_id, variable_id and symbol_id. The relationships are: project_id 1..* variable_id variable_id 1..1 symbol_id The following is a simple example:
p_id | v_id | s_id 1 | 1 | 1 2 | 1 | 2 3 | 1 | 3 4 | 1 | 4 1 | 2 | 5 2 | 2 | 6 3 | 2 | 7 4 | 2 | 8 2 | 3 | 9 4 | 3 | 10 1 | 4 | 11 2 | 4 | 12 4 | 4 | 13 3 | 5 | 14
this would be stored in an AoA called @results, where each row is an array of project_id, variable_id and symbol_id, where a row is an element of @results. From this I would like to create a table like so:
| p_1 | p_2 | p_3 | p_4 | --------------------------------- v_1 | s_1 | s_2 | s_3 | s_4 | v_2 | s_5 | s_6 | s_7 | s_8 | v_3 | | s_9 | | s_10 | v_4 | s_11 | s_12 | | s_13 | v_5 | | | s_14 | |
It doesnt matter too much if the pipelines are there or not, I just need the data aligned for easy reading. At the moment I use nested for loops to generate this. This becomes a problem when a symbol doesnt exist for a particular variable in a project. The way it works is it appends a symbol to a string named $row when it exists...if it doesnt nothing happens, so I get something like the following table...
| p_1 | p_2 | p_3 | p_4 | --------------------------------- v_1 | s_1 | s_2 | s_3 | s_4 | v_2 | s_5 | s_6 | s_7 | s_8 | v_3 | s_9 | s_10 | v_4 | s_11 | s_12 | s_13 | v_5 | s_14 |
Any ideas how I might solve this? Thanks, Steve

In reply to Create a table from a matrix by Anonymous Monk

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!
  • 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, details, 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, summary, 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.