murtu_4u has asked for the wisdom of the Perl Monks concerning the following question:
%a = {} ; $a{"KEY1"}->{"VALUE1"}->{key} = value11 ; $a{"KEY1"}->{"VALUE2"}->{key} = value21 ; $a{"KEY2"}->{"VALUE1"}->{key} = value11 ; $a{"KEY2"}->{"VALUE2"}->{key} = value21 ;
So u see, there is a hash, whose keys have values that each point to another hash. Basically im storing some network data which is initially indexed by the source MAC address and for each source MAC address i have several destination MAC addresses. and then for each of these source destination pairs i have some key value pairs like numBytesTransferred, numRetries etc.
The problem1. foreach $source (keys %allData) 2. { 3. foreach $dest ( keys $allData{$source} ) 4. { 5. #access the values 6. } 7. }
Line 3 has an error that says "Type of arg 1 to keys must be hash (not hash element) at file.pl.."
Please help ! or suggest some alternative better way to organize the data that I have talked abt above. Thanks in advance.
MJ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple Anon Hash Query
by davido (Cardinal) on Jan 21, 2007 at 07:13 UTC | |
|
Re: Simple Anon Hash Query
by graff (Chancellor) on Jan 21, 2007 at 08:19 UTC | |
|
Re: Simple Anon Hash Query
by rodion (Chaplain) on Jan 21, 2007 at 12:57 UTC | |
|
Re: Simple Anon Hash Query
by logie17 (Friar) on Jan 21, 2007 at 21:56 UTC | |
by murtu_4u (Initiate) on May 27, 2008 at 16:15 UTC |