Try this
foreach $file (@sortlist){

open(LOG,$file) or die "Can't open $file: $!\n";
@lines = <LOG>;
foreach my $logline (reverse(@lines)) {

        #Search for Host-IP-Adress and bytes
    if( $logline =~ / (\d+\.\d+\.\d+\.\d+) \w*\/\w* (\d+) [A-Z]+/ ){
        if($ipload{$1}) {$ipload{$1}+=$2}
        else {$ipload{$1}=$2}
    }
}

#Close log file
close(LOG) or die "Can't close $file: $!\n";

#Print hash sorted by Host-IP-Adress
foreach $ip ( map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, (/(\d+)$/)[0] ] } keys %ipload) {
print "$ip = $ipload{$ip}\n";
}


Try this script out (replacing the fake filenames with actual ones)
and see if it will help you sort out what's happening:

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my %ipload = ();
my @sortlist = qw(file1 file2);

for my $file(@sortlist) {
open LOG, $file or die "Open $file: $!";
while(<LOG>) {
my ($ip,$bytes) = $_ =~ m/(\d+\.\d+\.\d+\.\d+) \w*\/\w* (\d+) [A-Z]+/;
$ipload{$ip} += $bytes if $ip && $bytes;
}
close LOG;
}


print Dumper \%ipload;

HTH :) - Lee.M - JupiterHost.Net

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to