""Chris Charley"" <char...@pulsenet.com> wrote in message news:20160912202839.22177.qm...@lists-nntp.develooper.com...
"Nathalie Conte" <nco...@ebi.ac.uk> wrote in message news:9d0654e0-8ec0-4051-87ca-541f90931...@ebi.ac.uk... 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).