Ok I figured out a solution:
#!/usr/bin/perl -w
use strict;
use Storable;
my %total_bytes;
my $all = "**all machines**";
my $output_file = 'storage';
if (-e $output_file) {
my $hashref = retrieve $output_file;
%total_bytes = %$hashref;
} else {
print "$output_file has not been generated.\n"
}
#stuff hash
while (<>) {
next if /^#/;
my ($source, $destination, $bytes) = split;
$total_bytes{$source}{$destination} += $bytes;
$total_bytes{$source}{$all} += $bytes;
}
#sort totals for $all
my @sources = sort {$total_bytes{$b}{$all} <=> $total_bytes{$a}{$all}}
keys %total_bytes;
#print out totals for destinations
for my $source(@sources){
my @destinations = sort {$total_bytes{$source}{$b} <=>
$total_bytes{$source}{$a}} keys %{$total_bytes{$source}};
print "$source: $total_bytes{$source}{$all} total bytes sent\n";
for my $destination (@destinations) {
next if $destination eq $all;
print " $source => $destination:", " $total_bytes{$source}
{$destination} bytes\n";
}
print "\n";
}
store { %total_bytes }, $output_file;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/