in reply to Re: Howto Dynamically Create a Hash?
in thread Howto Dynamically Create a Hash?

Just a note about my code design:

I didn't need to use a seperate lookup structure. I could just have interated over the keys of %hash (like Aristotle did). However, iterating over an array will return consistent results whereas iterating over a hash will not.

Given
@nlist = (9,3,27);
always gives
'A' => [9,27], 'B' => [3]
with my code, but can give either
'A' => [9,27], 'B' => [3]
or
'A' => [9], 'B' => [3,27]
(unpredicatbly) when iterating through %hash.

Replies are listed 'Best First'.
Re^3: Howto Dynamically Create a Hash?
by Aristotle (Chancellor) on Oct 09, 2005 at 23:05 UTC

    Did you read my code? I don’t iterate over any hash anywhere. Your claim that my code may produce inconsistent results is false.

    You stuck to the OP’s approach of shifting from the @key_list, which makes it unduly complicated to achieve consistency. I did not, so my code is simpler, but it is just as consistent.

    Makeshifts last the longest.

      Sorry, I added "(like Aristotle did)" via update after I saw your post. I guess i must have read it too quickly. My apologies.