bar10der has asked for the wisdom of the Perl Monks concerning the following question:
I want to print contents of a hash which itself is inside another hash.
This is how the code looks like-
Once %Queues is populated with %Hashes vals, how do I print/access elements of %Hashes inside %Queues.my %Queues; $sql = "a valid sql statement"; $sth = $dbh->prepare($sql); $sth->execute(); while (my @Row = $sth->fetchrow_array()) { my %Hashes; $Hashes{QueueID} = 0; $Hashes{Queue} = $CustomQueue; $Hashes{MaxAge} = 0; $Hashes{Count} = $Row[0]; #print "Record Count = $Row[0] \n"; push (@{$Queues{Queues}}, \%Hashes); # set some things if ($QueueId == 0) { $Queues{TicketsShown} = $Row[0]; $Queues{TicketsAvail} = $Row[0]; } }
When I do following I get error-
Any help will be greatly appreciated.while (my ($key,$value) = each(%Data)){ #print "$key = $value \n"; for(my ($k,$v) = each($key->{'Queues'})){ print "$k = $v \n"; } }
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing hash elements inside another hash
by toolic (Bishop) on Mar 11, 2009 at 14:35 UTC | |
|
Re: Accessing hash elements inside another hash
by kennethk (Abbot) on Mar 11, 2009 at 14:31 UTC | |
|
Re: Accessing hash elements inside another hash
by JavaFan (Canon) on Mar 11, 2009 at 14:58 UTC | |
by bar10der (Beadle) on Mar 11, 2009 at 15:05 UTC | |
by jrsimmon (Hermit) on Mar 11, 2009 at 17:35 UTC | |
by shmem (Chancellor) on Mar 11, 2009 at 23:08 UTC | |
|
Re: Accessing hash elements inside another hash
by Anonymous Monk on Mar 11, 2009 at 14:31 UTC |