Folker Naumann wrote:
Hi there!

Hello,

I'm fairly new to Perl and need some help to acomplish a (simple?) task.

I extract strings from some logfiles, namely an ip-adress and bytes, by using regexes. I use a hash to store ip-adress and associated bytes.


Sounds like you have the hard part done :)

First i packed all logs in a temporary file but it was getting too big.


Instead of createing a new file that has each fuile in it (doubling the space and memeory used) process them one ata time:

my %ipbytes = ();


for my $file(@logfiles) {

open LOG, $file or die $1;
while(<LOG>) {
my ($ip,$bytes) = split /\:/, $_; # or however you get the ip and bytes from a line
$ipbytes{$ip} += $bytes; # may want top make sure $bytes is numeric to avoid possible errors
}
close LOG;
}



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