in reply to Re^2: Using 'each' to get random (key, value) pair from hash returns "uninitialized value"
in thread Using 'each' to get random (key, value) pair from hash returns "uninitialized value"
To the question in your previous post I would say that should work. Nice line by the way. UPDATE: Seems it won't work after all, see johngg's experiment
But the delete bevor add idea won't work, because hashed items get stored into specific slots depending on their hash value. I.e. new passengers always want to go to a seat that depends on their social security number, not to the seat that was vacated last.
What happens when a passengers wants a seat that is occupied, There are two mayor strategies to handle this (that I remember), one is to let more than one passenger sit on a seat, the other is to calculate another seat in a deterministic pattern until the passenger finds a free one (for example the next seat, or the 13th seat from this one). I believe perl hashes use the first method (more than one on a seat) but I'm not sure.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using 'each' to get random (key, value) pair from hash returns "uninitialized value"
by johngg (Canon) on Jan 29, 2011 at 00:26 UTC | |
by jethro (Monsignor) on Jan 29, 2011 at 01:09 UTC | |
by johngg (Canon) on Jan 29, 2011 at 18:53 UTC | |
by puterboy (Scribe) on Jan 29, 2011 at 23:11 UTC |