in reply to reference as hash keys and values
Of course you can combine the elements of a multiple key into one string, but that only proves that the key to a hash is a single string.
Another solution is to spread out the elements of your multiple keys over different levels of the hash.
Something like this:
$hash{a}->{b} will then return the arrayref to the array 1, 2, 3, and so on.my %hash = ( a => { b => [1, 2, 3], c => [4, 5, 6], }, b => { d => [7, 8, 9], e => [10, 11, 12], }, );
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: reference as hash keys and values
by Don Coyote (Hermit) on Jul 10, 2011 at 21:20 UTC |