← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:13 2021

Filename/usr/local/lib/perl5/site_perl/MIME/Parser/Results.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMIME::Parser::Results::::BEGIN@42MIME::Parser::Results::BEGIN@42
0000s0sMIME::Parser::Results::::BEGIN@45MIME::Parser::Results::BEGIN@45
0000s0sMIME::Parser::Results::::errorsMIME::Parser::Results::errors
0000s0sMIME::Parser::Results::::indentMIME::Parser::Results::indent
0000s0sMIME::Parser::Results::::levelMIME::Parser::Results::level
0000s0sMIME::Parser::Results::::msgMIME::Parser::Results::msg
0000s0sMIME::Parser::Results::::msgsMIME::Parser::Results::msgs
0000s0sMIME::Parser::Results::::newMIME::Parser::Results::new
0000s0sMIME::Parser::Results::::top_headMIME::Parser::Results::top_head
0000s0sMIME::Parser::Results::::warningsMIME::Parser::Results::warnings
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package MIME::Parser::Results;
2
3=head1 NAME
4
5MIME::Parser::Results - results of the last entity parsed
6
7
8=head1 SYNOPSIS
9
10Before reading further, you should see L<MIME::Parser> to make sure that
11you understand where this module fits into the grand scheme of things.
12Go on, do it now. I'll wait.
13
14Ready? 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
33Results from the last MIME::Parser parse.
34
35
36=head1 PUBLIC INTERFACE
37
38=over 4
39
40=cut
41
42use strict;
43
44### Kit modules:
45use MIME::Tools qw(:msgs);
46
47
48#------------------------------
49
50=item new
51
52I<Constructor.>
53
54=cut
55
56sub new {
57 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
69I<Instance method.>
70Return all messages that we logged, in order.
71Every message is a string beginning with its type followed by C<": ">;
72the current types are C<debug>, C<warning>, and C<error>.
73
74=cut
75
76sub msgs {
77 @{shift->{MPI_Msgs}};
78}
79
80#------------------------------
81
82=item errors
83
84I<Instance method.>
85Return all error messages that we logged, in order.
86A convenience front-end onto msgs().
87
88=cut
89
90sub errors {
91 grep /^error: /, @{shift->{MPI_Msgs}};
92}
93
94#------------------------------
95
96=item warnings
97
98I<Instance method.>
99Return all warning messages that we logged, in order.
100A convenience front-end onto msgs().
101
102=cut
103
104sub warnings {
105 grep /^warning: /, @{shift->{MPI_Msgs}};
106}
107
108#------------------------------
109
110=item top_head
111
112I<Instance method.>
113Return the topmost header, if we were able to read it.
114This may be useful if the parse fails.
115
116=cut
117
118sub top_head {
119 my ($self, $head) = @_;
120 $self->{MPI_TopHead} = $head if @_ > 1;
121 $self->{MPI_TopHead};
122}
123
- -
127#------------------------------
128#
129# PRIVATE: FOR USE DURING PARSING ONLY!
130#
131
132#------------------------------
133#
134# msg TYPE, MESSAGE...
135#
136# Take a message.
137#
138sub msg {
139 my $self = shift;
140 my $type = shift;
141 my @args = map { defined($_) ? $_ : '<<undef>>' } @_;
142
143 push @{$self->{MPI_Msgs}}, ($type.": ".join('', @args)."\n");
144}
145
146#------------------------------
147#
148# level [+1|-1]
149#
150# Return current parsing level.
151#
152sub level {
153 my ($self, $lvl) = @_;
154 $self->{MPI_Level} += $lvl if @_ > 1;
155 $self->{MPI_Level};
156}
157
158#------------------------------
159#
160# indent
161#
162# Return indent for current parsing level.
163#
164sub indent {
165 my ($self) = @_;
166 ' ' x $self->{MPI_Level};
167}
168
169=back
170
171=cut
172
1731;
174__END__