I would like to write a routine for reading logs but it enters into a loop and the CPU is almost completely taken. Can you suggest something?
-------
open(UIL,"$logs"
;
@in=<UIL>;
foreach $on (@in){
split(/\|/,$on);
push(@a, $_[0]);
push(@b, $_[0]);}
foreach $c (@a){
$x=0;
foreach $y (@z){
if ($c eq $y){$k=$c;}}
if ($c ne $k){
foreach $d (@b){
if ($d eq $c){
push(@z,"$d"
;$x++;}}}
if ($x >0){
open(T,">>report/log.rep"
;print T"$x|$c|\n";}
}
open(T,"report/log.rep"
;
@T=<T>;
foreach $l (@T){
@T1=split(/\|/,$l);
open (TMP2,"file.html"
;
while (<TMP2>) {$_=~s/\[date\]/$T1[0]/g;$_=~s/\[calls\]/$T1[1]/g;
print $_;}
}
-------
This counts the no. of call per day ($_[0]) but when the log file is too big (i.e. 2Mb) it cannot generate the report. It seems a loop
I read the log file, then I push the dates into 2 arrays. Then I compare them: I count how many times the date is repeated. The results are printed in a report file (rep.log).
Sorry. This is the first time I make something like this ... on big files!
Here is an example of the original log file (the real file is around 2Mb):
-----
10/15/2000|hour|ip
10/15/2000|hour|ip
10/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
----
The rep.log should be like this:
----
10/15/2000|3
11/15/2000|4
----
Thanks in advance.
[sig][/sig]
-------
open(UIL,"$logs"
@in=<UIL>;
foreach $on (@in){
split(/\|/,$on);
push(@a, $_[0]);
push(@b, $_[0]);}
foreach $c (@a){
$x=0;
foreach $y (@z){
if ($c eq $y){$k=$c;}}
if ($c ne $k){
foreach $d (@b){
if ($d eq $c){
push(@z,"$d"
if ($x >0){
open(T,">>report/log.rep"
}
open(T,"report/log.rep"
@T=<T>;
foreach $l (@T){
@T1=split(/\|/,$l);
open (TMP2,"file.html"
while (<TMP2>) {$_=~s/\[date\]/$T1[0]/g;$_=~s/\[calls\]/$T1[1]/g;
print $_;}
}
-------
This counts the no. of call per day ($_[0]) but when the log file is too big (i.e. 2Mb) it cannot generate the report. It seems a loop
I read the log file, then I push the dates into 2 arrays. Then I compare them: I count how many times the date is repeated. The results are printed in a report file (rep.log).
Sorry. This is the first time I make something like this ... on big files!
Here is an example of the original log file (the real file is around 2Mb):
-----
10/15/2000|hour|ip
10/15/2000|hour|ip
10/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
11/15/2000|hour|ip
----
The rep.log should be like this:
----
10/15/2000|3
11/15/2000|4
----
Thanks in advance.
[sig][/sig]