Dotproducts and angles bring back scary memories from my uni days, so I'm not going to go there :)

pzbagel was right in saying that the ordering of hashes in Perl is not deterministic: nothing guarantees that you always get stuff out in the same order as you put them in (in fact, given the nature of the hashing algorithm, you are virtually guaranteed that you get them out in a different order than they went in). If you want to guarantee a consistent order (though not necessarily the initial order), use sort on the list returned by keys %hash.

However, this seems to be more of a case for arrays than hashes. As you say, all your hashes have identical keys, both in number and name. If you want to associate some kind of descriptive name to the array elements, keep a seperate array of names. Something like this:

my @names=qw/value1 value2 value3/; my @array1=(1, 2, 3); my @array2=(4, 5, 6);
Or even use an AoA to store your actual data:
my @AoA; push @AoA, [ 1,2,3 ]; push @AoA, [ 4,5,6 ]; #Then use them as such: $AoA[0][0]; # 1st element of first array $AoA[1][0]; # 1st element of second array

CU
Robartes-


In reply to Re: Lining up many hash values by robartes
in thread Lining up many hash values by Evanovich

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.