CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Hash of hashes distribution of elements



Feb 24, 2014, 6:00 AM

Post #1 of 1 (2122 views)
Hash of hashes distribution of elements Can't Post

I have a %HoH that look like this:

HoH{key}{a/b/c or d}{"a number"}

How do I create a distribution of values in each of the 4 different types. I would like an output a bit like this:

type a: 1 - 1 time, 2 - 2 times, 3 - 4 times, 4- 9 times, 5 - 14 times etc.

I can do this if I create 4 arrays, but that can't be the smartest. How should I do it?

Any text/junk code example would be fine, so I can get the idea.

Best regards

I can print it like this:
# Print data:
sub printsimple {
foreach my $key ( keys %HoH ) {
print "$key\n";
foreach my $property ( keys %{ $HoH{$key} } ) {
print " $property => $HoH{$key}{$property}\n";


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives