in reply to Extracting data from nested hashes

To get the derived statistics, loop over all the indices and count:
my %table; # The number of items of group $d of length N (where N is 1 to a # max. length determined elsewhere) found in $b. for my $file (keys %a) { for my $group (keys %{$a{$file}}) { for my $subgroup (keys %{$a{$file}{$group}}) { for my $length (@{$a{$file}{$group}{$subgroup}}) { $table{$file}{$subgroup}[$length]++; } } } }
To print out a table, use another nested loop:
my $file = 'xxx'; for my $length (1..$max_length) { for my $unique_d (keys %{$a{$file}{$group}}) { # printing stuff using $table{$file}{$unique_d}[$length] } }
Update: fixed a typo in the second comment.

-Mark

Replies are listed 'Best First'.
Re^2: Extracting data from nested hashes
by knirirr (Scribe) on Nov 17, 2004 at 17:38 UTC
    Looks interesting, thanks. I was trying something similar, but having dreadful trouble getting it to work properly - I suspect due to incorrect use of the keys %{$a{$file}{$group}}) syntax.