in reply to Picking a random item through probability
Note that it has converted your Arrayref ["foo",1] into a KEY, which is probably not what you want. In any case, a hash-type structure does not seem to be called for , based on your description. I'd sugges an AoA.$VAR1 = { 'ARRAY(0x19333b0)' => [ 'baz', 5 ], 'ARRAY(0x350c8)' => [ 'bar', 7 ] };
my @Index_Is_The_Weight=( [], # Zero weight - no items ["foo"], # Only one item has weight ONE [], # No items in weight 2 ["bar"], # Three ([]) x 5, # Five empty items ["quux"] );
"A closed mouth gathers no feet." --Unknown
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Picking a random item through probability
by GrandFather (Saint) on Nov 23, 2006 at 21:23 UTC | |
by Tanktalus (Canon) on Nov 23, 2006 at 21:37 UTC | |
by muba (Priest) on Nov 23, 2006 at 21:56 UTC | |
by Tanktalus (Canon) on Nov 23, 2006 at 22:14 UTC | |
by doom (Deacon) on Nov 24, 2006 at 01:02 UTC | |
by muba (Priest) on Nov 23, 2006 at 22:51 UTC |