Hello all!
I am working on trying to figure out how to print out a hash of hashes. How the hash in the code is defined below is very similar to how the hash is defined in the script I am working with. (Yes, this is for work so I cannot share the actual code, sorry).
I was using this web page as a reference for figuring this out as it has been of great assistance before, but for some reason, the code below prints out NOTHING.
Why? I am not sure but I am hopeful that someone can tell me why and what I am doing wrong.
Thanks in advance for any and all help!
Best regards,
Jeff
I am working on trying to figure out how to print out a hash of hashes. How the hash in the code is defined below is very similar to how the hash is defined in the script I am working with. (Yes, this is for work so I cannot share the actual code, sorry).
I was using this web page as a reference for figuring this out as it has been of great assistance before, but for some reason, the code below prints out NOTHING.
Why? I am not sure but I am hopeful that someone can tell me why and what I am doing wrong.
Code:
use strict; use warnings; my %hash1; my $hash2; $hash2 = 1; $hash1{$hash2}{key1} = 1; $hash1{$hash2}{key2} = 2; $hash1{$hash2}{key3} = 3; for my $keys1 (keys %$hash1){ for my $keys2 (keys %{hash1->{$keys1}}){ print "The value of hash1->$keys1->$keys2 is: $hash1->{$keys1}{$keys2}\n" } }
Best regards,
Jeff
Comment