sub report_one { my ($input_handle, $output_name) = @_; open(my $OUT, '>', "$output_name") || croak "Cannot open output file: $!\n"; my $current_host = ""; my %host_counts; my @rows = (<$input_handle>); foreach ( @rows ) { my ($date, $time, $host, $bytes, $bytes_sec, $server) = split /\t/; if ( ( $bytes < 1000000 ) || ( $bytes == $bytes_sec ) ) { next; } if ( $host eq $current_host ) { $host_counts{$host}{bytes} += $bytes; $host_counts{$host}{speed} += $bytes_sec; $host_counts{$host}{count}++; } else { $host_counts{$host}{bytes} = $bytes; $host_counts{$host}{speed} = $bytes_sec; $host_counts{$host}{count} = 1; } $current_host = $host; } foreach my $heauxst ( keys %host_counts ){ my $avg_speed = int( $host_counts{$heauxst}{speed} / $host_counts{$heauxst}{count} ); print $OUT "$heauxst\t$host_counts{$heauxst}{bytes}\t$avg_speed\n"; } close $OUT; return; }