line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MIME::Parser::Results; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
MIME::Parser::Results - results of the last entity parsed |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 SYNOPSIS |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Before reading further, you should see L to make sure that |
11
|
|
|
|
|
|
|
you understand where this module fits into the grand scheme of things. |
12
|
|
|
|
|
|
|
Go on, do it now. I'll wait. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Ready? Ok... |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
### Do parse, get results: |
17
|
|
|
|
|
|
|
my $entity = eval { $parser->parse(\*STDIN); }; |
18
|
|
|
|
|
|
|
my $results = $parser->results; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
### Get all messages logged: |
21
|
|
|
|
|
|
|
@msgs = $results->msgs; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
### Get messages of specific types (also tests if there were problems): |
24
|
|
|
|
|
|
|
$had_errors = $results->errors; |
25
|
|
|
|
|
|
|
$had_warnings = $results->warnings; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
### Get outermost header: |
28
|
|
|
|
|
|
|
$top_head = $results->top_head; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 DESCRIPTION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Results from the last MIME::Parser parse. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 PUBLIC INTERFACE |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
15
|
|
|
15
|
|
340
|
use strict; |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
401
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
### Kit modules: |
45
|
15
|
|
|
15
|
|
65
|
use MIME::Tools qw(:msgs); |
|
15
|
|
|
|
|
28
|
|
|
15
|
|
|
|
|
6587
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
#------------------------------ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
I |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new { |
57
|
53
|
|
|
53
|
1
|
419
|
bless { |
58
|
|
|
|
|
|
|
MPI_ID => 'MIME-parser', |
59
|
|
|
|
|
|
|
MPI_Msgs => [], |
60
|
|
|
|
|
|
|
MPI_Level => 0, |
61
|
|
|
|
|
|
|
MPI_TopHead => undef, |
62
|
|
|
|
|
|
|
}, shift; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#------------------------------ |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item msgs |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
I |
70
|
|
|
|
|
|
|
Return all messages that we logged, in order. |
71
|
|
|
|
|
|
|
Every message is a string beginning with its type followed by C<": ">; |
72
|
|
|
|
|
|
|
the current types are C, C, and C. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub msgs { |
77
|
0
|
|
|
0
|
1
|
0
|
@{shift->{MPI_Msgs}}; |
|
0
|
|
|
|
|
0
|
|
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#------------------------------ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item errors |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
I |
85
|
|
|
|
|
|
|
Return all error messages that we logged, in order. |
86
|
|
|
|
|
|
|
A convenience front-end onto msgs(). |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub errors { |
91
|
0
|
|
|
0
|
1
|
0
|
grep /^error: /, @{shift->{MPI_Msgs}}; |
|
0
|
|
|
|
|
0
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#------------------------------ |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item warnings |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
I |
99
|
|
|
|
|
|
|
Return all warning messages that we logged, in order. |
100
|
|
|
|
|
|
|
A convenience front-end onto msgs(). |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub warnings { |
105
|
0
|
|
|
0
|
1
|
0
|
grep /^warning: /, @{shift->{MPI_Msgs}}; |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
#------------------------------ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item top_head |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
I |
113
|
|
|
|
|
|
|
Return the topmost header, if we were able to read it. |
114
|
|
|
|
|
|
|
This may be useful if the parse fails. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub top_head { |
119
|
218
|
|
|
218
|
1
|
330
|
my ($self, $head) = @_; |
120
|
218
|
100
|
|
|
|
521
|
$self->{MPI_TopHead} = $head if @_ > 1; |
121
|
218
|
|
|
|
|
753
|
$self->{MPI_TopHead}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#------------------------------ |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
# PRIVATE: FOR USE DURING PARSING ONLY! |
130
|
|
|
|
|
|
|
# |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#------------------------------ |
133
|
|
|
|
|
|
|
# |
134
|
|
|
|
|
|
|
# msg TYPE, MESSAGE... |
135
|
|
|
|
|
|
|
# |
136
|
|
|
|
|
|
|
# Take a message. |
137
|
|
|
|
|
|
|
# |
138
|
|
|
|
|
|
|
sub msg { |
139
|
22
|
|
|
22
|
0
|
40
|
my $self = shift; |
140
|
22
|
|
|
|
|
37
|
my $type = shift; |
141
|
22
|
50
|
|
|
|
54
|
my @args = map { defined($_) ? $_ : '<>' } @_; |
|
55
|
|
|
|
|
167
|
|
142
|
|
|
|
|
|
|
|
143
|
22
|
|
|
|
|
38
|
push @{$self->{MPI_Msgs}}, ($type.": ".join('', @args)."\n"); |
|
22
|
|
|
|
|
158
|
|
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#------------------------------ |
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
# level [+1|-1] |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
# Return current parsing level. |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
sub level { |
153
|
337
|
|
|
337
|
0
|
529
|
my ($self, $lvl) = @_; |
154
|
337
|
50
|
|
|
|
974
|
$self->{MPI_Level} += $lvl if @_ > 1; |
155
|
337
|
|
|
|
|
694
|
$self->{MPI_Level}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#------------------------------ |
159
|
|
|
|
|
|
|
# |
160
|
|
|
|
|
|
|
# indent |
161
|
|
|
|
|
|
|
# |
162
|
|
|
|
|
|
|
# Return indent for current parsing level. |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
sub indent { |
165
|
22
|
|
|
22
|
0
|
40
|
my ($self) = @_; |
166
|
22
|
|
|
|
|
100
|
' ' x $self->{MPI_Level}; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
__END__ |