in reply to array in hashes
i have two hashes each of them contains an array for each key
No you don't.
First, there are no arrays anywhere in that code. Just lots of meaningless parens.
Secondly, hash values must be scalars, and arrays aren't scalars. You could store a reference to an array in a hash value, though.
my %genome1 = ( a => [ 10, 15 ], b => [ 3, 7 ], c => [ 9, 14 ], ); my %genome2 = ( d => [ 3, 21 ], a => [ 3, 4 ], g => [ 5, 10 ], b => [ 2, 7 ], ); for (keys(%genome1)) { if ($genome2{$_}) { print("Both genomes have key $_\n"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: array in hashes
by persianswallow (Novice) on Jul 29, 2011 at 09:04 UTC | |
by moritz (Cardinal) on Jul 29, 2011 at 09:18 UTC | |
by persianswallow (Novice) on Jul 29, 2011 at 09:36 UTC | |
by moritz (Cardinal) on Jul 29, 2011 at 09:54 UTC | |
by fisher (Priest) on Jul 29, 2011 at 10:07 UTC | |
by JavaFan (Canon) on Jul 29, 2011 at 10:19 UTC | |
| |
by persianswallow (Novice) on Jul 29, 2011 at 10:44 UTC |