""Chris Charley"" <[email protected]> wrote in message 
news:[email protected]...

"Nathalie Conte" <[email protected]> wrote in message 
news:[email protected]...
Dear all, 

[snip]

many thanks again for any tips/help,
Nathalie


[Chris wrote]

[snip]

for my $name (sort keys %hall) {
    my $href = $hall{$name};
    my @keys = uniq sort {$a <=> $b} map keys %$_, values %$href;
    
    for my $i (0 .. $#keys) {
        for my $j ($i+1 .. $#keys) {
            my $sum = sum( map $_->{$keys[$j]}, values %$href) - 
                               sum( map $_->{$keys[$i]}, values %$href);
            printf "%s $keys[$j] minus $keys[$i] %s\n", $name, $sum;
        }
    }
}

Update: That print line is better written:
print "$name $keys[$j] minus $keys[$i] $sum\n";

And, to be a bit safer, the 2 calculated sums should be:
sum( map $_->{$keys[$j]} || 0, values %$href) 
sum( map $_->{$keys[$i]} || 0, values %$href);

where $_->{ $keys[$j] } and $_->{ $keys[$i] } default to ‘0’ if not contained 
in the hash (which doesn’t happen in the sample data provided anyhow).

Reply via email to