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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



mk_bold
Novice

Feb 24, 2014, 6:00 AM

Post #1 of 1 (804 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
Kirkegaard

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