Thank you all in advance for your help!

It seems that I have setup an overly complicated multidimensional associated array and I was wondering if I could get some suggestions on how to simplify my data structure. If it turns out that I cannot simplify my multidimensional array, than I was hoping to get a few tips on how to work with this data. Here is a bit of background on the situation:

BACKGROUND- I have multiple data sets each containing points in 3D space. I have gone ahead and calculated all of the possible distances between any two points between and within each data set. For example (using set notation), let's say I have Set1 = {a,b,c}, Set2 = {d,e,f,g}, and Set3 = {h,i} (unfortunately, in real life the points do not have unique identifiers relative to other sets; for example, the identifier for "a","d", and "h" would all be "1" and the identifier for "b","e", and "i" would all be "2"). I believe I have setup a hash of hashes of hashes of hashes to hold my data. Therefore, the distance between "a" and "d" would be held in $matrix{set1}{a}{set2}{d}, the distance between "h" and "i" would be held in $matrix{set3}{h}{set3}{i}, and so on. I should also note that distances are not redundant. Therefore, I have stored the distance from "a" to "b" but not from "b" to "a". I have also not calculated the distance between a point and itself (i.e. from "a" to "a" or "b" to "b"). This was done to save memory and calculation time.

GOAL- I would like to print out an Excel file that contains all of the distances between the points of any two sets. Therefore, I would like to have a file containing Set1 vs. Set2. Using set notation, the Set1vSet2.xls would contain {AD,AE,AF,AG,BD,BE,BF,BG,CD,CE,CF,CG} where AD represented the distance between point "a" and point "d". Ultimately, I would like to have every combination of sets: Set1vSet1.xls, Set1vSet2.xls, Set1vSet3.xls, Set2vSet2.xls, Set2vSet3.xls, and Set3vSet3.xls.

WHERE I AM NOW- Here is some pseudocode on how I think this could work:

foreach firstSet { foreach firstPoint { foreach secondSet { foreach secondPoint { print distance to firstSetVsecondSet.xls } } } }
I think this code would loop through the entire matrix and print out the necessary point in the correct files. Unfortunately, I'm not sure how to implement this with my current data structure setup.

I hope I have made this as clear as possible. Please let me know if I can explain anything further. Many many thanks for your help!


In reply to Hash of Hashes of Hashes of Hashes by Comment

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.