Annotation of capa/capa51/CapaTools/loganalysis.pl, revision 1.1.1.1
1.1 albertel 1: #!/usr/local/bin/perl
2:
3: require('getopts.pl');
4:
5:
6:
7: sub S_Enterpath {
8: local($set)=@_;
9: local($notdone,$path);
10:
11: $notdone = 1;
12: while ($notdone) {
13: print "Please enter the CLASS absolute path:\n";
14: $path = <>; chomp($path);
15: if( $path =~ /\/$/ ) {
16: $Rfullpath = "$path" . "records";
17: $Lfullpath = "$path" . "records/log$set.db";
18: $Wfullpath = "$path" . "records/weblog$set.db";
19: } else {
20: $Rfullpath = "$path" . "/records";
21: $Lfullpath = "$path" . "/records/log$set.db";
22: $Wfullpath = "$path" . "/records/weblog$set.db";
23: }
24: if( -d $path ) {
25: if( -d $Rfullpath ) {
26: if( -f $Lfullpath ) {
27: $notdone = 0;
28: } else {
29: print "File [$Lfullpath] does not exist!\n";
30: }
31: if( -f $Wfullpath ) {
32: $notdone = 0;
33: } else {
34: print "File [$Wfullpath] does not exist!\n";
35: }
36: } else {
37: print "Directory [$Rfullpath] does not exist!\n";
38: }
39: } else {
40: print "Directory [$path] does not exist!\n";
41: }
42:
43: }
44: return ($path);
45: }
46:
47: sub S_ScanDB {
48: local($filename)=@_;
49: local($line_cnt)=0;
50: local($s_num,$dow,$mon,$sp,$day,$time,$yr,$ans_str);
51: local(@ans_char);
52: local($ii,$first);
53: local($Yes_cnt,$No_cnt);
54:
55: open(IN, "<$filename") || die "Cannot open $filename file!";
56: $Yes_cnt = 0; $No_cnt = 0;
57: while (<IN>) {
58: $line_cnt++;
59: chomp();
60: ($first,$ans_str) = split(/1997 /);
61: # print "$ans_str\n";
62: (@ans_char) = split(/ */,$ans_str);
63:
64: for($ii=0;$ii<=$#ans_char;$ii++) {
65:
66: $Yes_cnt++ if $ans_char[$ii] eq 'Y';
67:
68: $No_cnt++ if $ans_char[$ii] eq 'N';
69: }
70: }
71: close(IN) || die "Cannot close $filename file!";
72: print "$filename contains $line_cnt lines.\n";
73: print " Yes = $Yes_cnt, No = $No_cnt\n";
74: return ($Yes_cnt,$No_cnt);
75: }
76:
77:
78:
79: if(! &Getopts('s:') ) {
80: print STDERR "$Usage\n";
81: exit 2;
82: }
83: $opt_s = 1 if ! $opt_s;
84: S_Enterpath($opt_s);
85:
86: ($Y_cntL,$N_cntL) = S_ScanDB("$Lfullpath");
87: ($Y_cntW,$N_cntW) = S_ScanDB("$Wfullpath");
88: $Yratio = 0.0; $Nratio = 0.0;
89: $Yratio = $Y_cntW / $Y_cntL;
90: $Nratio = $N_cntL / $N_cntW;
91:
92: printf " Y ratio = %5.2f, N ratio = %5.2f\n", $Yratio , $Nratio;
93:
94:
95:
96:
97:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>