in reply to Hash value
Printing the reverse of a hash does not reverse keys and values in the hash. For that to happen you must re-assign the reversed data back to the hash:
The order in which a hash "prints" (or the order of the result of the keys, values or each function) is not random but determined by the internal hashing algorithm. For security reasons the order is likely to change between executions of your script although it is guaranteed to be the same order within one run of your script on the same (unmodified) hash.%hash = reverse %hash;
So you cannot easily predict the order. If you need the keys (or values) ordered, the best way is to use sort.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash value
by Bloodnok (Vicar) on Feb 10, 2009 at 11:21 UTC |