estreb has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to print each value in the hash ('here', 'there', 'hello', and 'world'). I tried the following, but it is giving me a syntax error in the second foreach loop:my %hash_of_hash_of_arrays = ( 'key' => { 'innerkey2' => [ 'here' ], 'innerkey3' => [ 'there' ], 'innerkey1' => [ 'hello', 'world' ] } );
The second foreach loop is incorrect. I have no idea if the third is even in the right ballpark. How do I fix this? Thanks in advance.foreach my $outerkey (keys %hash_of_hash_of_arrays) { print "'$outerkey'"; foreach my $innerkey (keys %hash_of_hash_of_arrays{$outerkey}) { print "\t'$hash_of_hash_of_arrays{$outerkey}{$innerkey}'"; foreach my $array_item (@{ $hash_of_hash_of_arrays{$outerkey}{$inn +erkey} }) { print "array item: $array_item"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: printing all values in a hash of hashes of arrays
by toolic (Bishop) on Dec 15, 2014 at 19:26 UTC | |
Re: printing all values in a hash of hashes of arrays
by GrandFather (Saint) on Dec 15, 2014 at 19:51 UTC | |
by BillKSmith (Monsignor) on Dec 15, 2014 at 21:08 UTC | |
Re: printing all values in a hash of hashes of arrays
by CountZero (Bishop) on Dec 15, 2014 at 21:39 UTC |