line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::Stats::Parser; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use Mail::Stats::Record; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use vars qw($Start_Header $Status_Header $Ignore_Header $End_Header); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
355
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$Start_Header = 'From \S+\s+\w\w\w \w\w\w\s+\d+ \d+:\d+:\d+ \d+'; |
9
|
|
|
|
|
|
|
$Status_Header = '(X-)?Status:'; |
10
|
|
|
|
|
|
|
$Ignore_Header = 'Subject: DON\'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA'; |
11
|
|
|
|
|
|
|
$End_Header = '\s*'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub parse { |
14
|
0
|
|
|
0
|
0
|
|
my $fh = shift; |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $mail = new Mail::Stats::Record(); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $header = 0; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
while(<$fh>) { |
21
|
0
|
0
|
0
|
|
|
|
if(/^From \S+\s+\w+ \w+\s+\d+ \d+:\d+:\d+ \d+/) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$header = 1; |
23
|
0
|
|
|
|
|
|
$mail->{MESSAGES}++; |
24
|
|
|
|
|
|
|
} elsif ($header && /^$Status_Header/og) { |
25
|
0
|
|
|
|
|
|
while(/(\w)/g) { |
26
|
0
|
|
|
|
|
|
$mail->{STATUS}->{$1}++; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} elsif ($header && /^$Ignore_Header/o) { |
29
|
0
|
|
|
|
|
|
$mail->{MESSAGES}--; |
30
|
0
|
|
|
|
|
|
$header = 0; |
31
|
|
|
|
|
|
|
} elsif ($header && /^$End_Header$/o) { |
32
|
0
|
|
|
|
|
|
$header = 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $mail; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |