in reply to Reversing Hash
$rev_hash{1 20 3} = "key1"
$rev_hash{1 9 17} = "key4 key5"
$rev_hash{1 9 8} = "key3"
$rev_hash{1 30 4 7} = "key2"
Which doesn't reduce the keys to its minimum possible.
I like to have keys "3" "1 17" "1 8" and "4" .
so the answer should be
$rev_hash{3} = "key1"
$rev_hash{1 17} = "key4 key5"
$rev_hash{1 8} = "key3"
$rev_hash{4} = "key2"
Update: I think question is mis-understood by most first-answeres. Above example would make it clear.
Update2: Hofmator gave a more correct solution at Re: Re: Re: Reversing Hash as it reduces most elements in total. I overlooked that earlier and should have produced a better example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reversing Hash
by Aristotle (Chancellor) on Mar 03, 2003 at 14:30 UTC |