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:
Or even use an AoA to store your actual data:my @names=qw/value1 value2 value3/; my @array1=(1, 2, 3); my @array2=(4, 5, 6);
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |