in reply to Hash Nightmare
To use your data structures, you can do this:
The better way to do it, as merlyn said, is to create your nested data structure from the top. Rather than creating (N) different hashes with the same keys, create a list of hash references (just like @allhashes above), and populate that with whatever method you are populating your hashes with now.#create list of hashes my @allhashes = ( \%hash1, \%hash2, \%hash3 ); #note the following assumes all keys exist and are the same #keys are not sorted in this example foreach my $key (keys %hash1) { print "key $key\n"; foreach my $hash (@allhashes) { print "Value: $hash->{$key}\n"; } }
Re-Update: Deleted a bunch of stuff that I thought was relevant, but wasn't.
|
|---|