in reply to Retriving data from Hash of Hashes
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $hohref; # No need to specify empty hash. $hohref->{h1} = {}; # Perl "autovivifies" the undefined reference. $hohref->{names} = { name1 => 'Chandra' }; my $epout = rand 9; my $tcid = substr $epout, 4, 9; $hohref->{$tcid} = { TCDesc => 'Login Test', TCRun => 'Yes', TCResult => 'Pass', }; my %tch = %$hohref; my @k = keys(%tch); my @v = values(%tch); print "The keys of ******* @k","\n"; print "The values of ******* @v ","\n"; my %och = %$hohref; for my $k (keys %och) { print "The key outer hash \t$k\t The value outer hash $och{$k}\n"; if('HASH' eq ref $och{$k}) { my %inner = %{ $och{$k} }; for (keys %inner) { print "The key is $_ ===> The value is $inner{$_}\n"; } } } print Dumper($hohref);
|
|---|