in reply to Re^3: Accessing hash elements inside another hash
in thread Accessing hash elements inside another hash
You're use of $key in the inner loop is incorrect.
Yours is too... a hash reference cannot be stored (directly) as a hash key, only as value. so that should look like
my %Data = getQueues(); while (my ($key,$value) = each(%Data)){ #print "$key = $value \n"; for(my ($k,$v) = each(%$value)){ print "$k = $v \n"; } }
although that snippet doesn't fit the OP's data structure, either. The following might work:
while (my ($key,$value) = each(%Data)){ if (ref $value eq 'ARRAY') { for my $hashref (@$value) { print " $_ => $hashref->{$_}\n" for keys %$hashref; } } else { print "$key = $value \n"; }
|
|---|