mark_briscombe has asked for the wisdom of the Perl Monks concerning the following question:
Then to check for existence of a key it would be :%hash=("$country"=>{ "$errorcode=>{ $messagetype=>{ "count"=>"value"}}})
Then we get onto the problem of printing the darn thing.if (defined $hash{$country}{$errorcode}{$message}{$count}) { $hash{$country}{$errorcode}{$message}{$count}+=1; } else { $hash{$country}{$errorcode}{$message}{$count}=1; }
I have tried various combinations, but a lot of the time I am getting warnings back saying that I do not have even amounts of values in my hash, meaning that I don’t have a straight key to value relationship, so I must be missing something obvious here! Any tips you have for me would be greatly appreciated.for $varctry(keys %hash) { for $varerror(@$hash{$varctry}) { for $varmsgtype(@$hash{$varctry}{$varerror}) { print "Country $varctry with error $varerror for msg $varmsgtype h +as $hash{$varctry}{$varerror}{$varmsgtype}{count} errors\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 3 dimensional hashes!
by blue_cowdawg (Monsignor) on Apr 27, 2004 at 11:18 UTC | |
by mark_briscombe (Initiate) on Apr 27, 2004 at 13:14 UTC | |
|
Re: 3 dimensional hashes!
by TomDLux (Vicar) on Apr 27, 2004 at 14:39 UTC | |
|
Re: 3 dimensional hashes!
by Fletch (Bishop) on Apr 27, 2004 at 16:41 UTC | |
|
Re: 3 dimensional hashes!
by TomDLux (Vicar) on Apr 27, 2004 at 14:21 UTC |