Folker Naumann wrote:
John W. Krahn wrote:
This may work as it doesn't slurp the whole file(s) into memory:
use warnings;
use strict;
use Socket;
my %ipload;
{ local @ARGV = @sortlist;
while ( <> ) {
next unless / (\d+\.\d+\.\d+\.\d+) \w*\/\w* (\d+) [A-Z]+/
my $ip = inet_aton( $1 ) or do {
warn "$1 is an invalid IP address.\n";
next;
};
$ipload{ $1 } += $2
}
}
#Print hash sorted by Host-IP-Adress
for ( sort keys %ipload ) {
my $ip = inet_ntoa( $_ );
print "$ip = $ipload{$_}\n";
}
__END__
This gives me "Bad arg length for Socket::inet_ntoa, length is 13,
should be 4 at line..."
Sorry, the line:
$ipload{ $1 } += $2
should be:
$ipload{ $ip } += $2
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>