3 # Starting with your data structure from Exercise 2, rewrite the
4 # coconet.dat file so that it's in the same format, but sorted by source
5 # machine. Report each destination machine once per source machine along
6 # with total bytes transferred. The destination machines should be indented
7 # under the source machine name and be sorted by the machine name:
15 # lovey.howell.hut 97560
26 my ($src, $dst, $bytes) = split;
27 $hosts{$src}{$dst} = $bytes;
32 foreach (keys %{$hashref}) {
33 $total += $hashref->{$_};
37 foreach my $src (sort { sum($hosts{$b}) <=> sum($hosts{$a}) } keys %hosts) {
39 foreach my $dst (sort { $hosts{$src}{$b} <=> $hosts{$src}{$a} }
40 keys %{$hosts{$src}}) {
41 print " $dst $hosts{$src}{$dst}\n";