1Mail::Box::Search::GrepU(s3e)r Contributed Perl DocumentaMtaiioln::Box::Search::Grep(3)
2
3
4

NAME

6       Mail::Box::Search::Grep - select messages within a mail box like grep
7       does
8

INHERITANCE

10        Mail::Box::Search::Grep
11          is a Mail::Box::Search
12          is a Mail::Reporter
13

SYNOPSIS

15        use Mail::Box::Manager;
16        my $mgr    = Mail::Box::Manager->new;
17        my $folder = $mgr->open('Inbox');
18
19        my $filter = Mail::Box::Search::Grep->new
20           ( label => 'selected'
21           , in => 'BODY', match => qr/abc?d*e/
22           );
23
24        my @msgs   = $filter->search($folder);
25
26        my $filter = Mail::Box::Search::Grep->new
27          ( field => 'To'
28          , match => $my_email
29          );
30
31        if($filter->search($message)) {...}
32

DESCRIPTION

34       Try to find some text strings in the header and footer of messages.
35       Various ways to limit the search to certain header fields, the whole
36       header, only the body, the whole message, but even binary multiparts,
37       are provided for.
38
39       The name grep is derived from the UNIX tool grep, which means: "Get
40       Regular Expression and Print".  Although you can search using regular
41       expressions (the Perl way of them), you do not have to print those as
42       result.
43
44       Extends "DESCRIPTION" in Mail::Box::Search.
45

METHODS

47       Extends "METHODS" in Mail::Box::Search.
48
49   Constructors
50       Extends "Constructors" in Mail::Box::Search.
51
52       Mail::Box::Search::Grep->new(%options)
53           Create a UNIX-grep like search filter.
54
55            -Option    --Defined in       --Default
56             binaries    Mail::Box::Search  <false>
57             decode      Mail::Box::Search  <true>
58             delayed     Mail::Box::Search  <true>
59             deleted     Mail::Box::Search  <false>
60             deliver                        undef
61             field                          undef
62             in          Mail::Box::Search  <$field ? 'HEAD' : C<'BODY'>>
63             label       Mail::Box::Search  undef
64             limit       Mail::Box::Search  0
65             log         Mail::Reporter     'WARNINGS'
66             logical     Mail::Box::Search  'REPLACE'
67             match                          <required>
68             multiparts  Mail::Box::Search  <true>
69             trace       Mail::Reporter     'WARNINGS'
70
71           binaries => BOOLEAN
72           decode => BOOLEAN
73           delayed => BOOLEAN
74           deleted => BOOLEAN
75           deliver => undef|CODE|'DELETE'|LABEL|'PRINT'|REF-ARRAY
76             Store the details about where the match was found.  The search
77             may take much longer when this feature is enabled.
78
79             When an ARRAY is specified it will contain a list of references
80             to hashes.  Each hash contains the information of one match.  A
81             match in a header line will result in a line with fields
82             "message", "part", and "field", where the field is a
83             Mail::Message::Field object.  When the match is in the body the
84             hash will contain a "message", "part", "linenr", and "line".
85
86             In case of a CODE reference, that routine is called for each
87             match. The first argument is this search object and the second a
88             reference to same hash as would be stored in the array.
89
90             The "PRINT" will call printMatchedHead() or printMatchedBody()
91             when any matching header resp body line was found.  The output is
92             minimized by not reprinting the message info on multiple matches
93             in the same message.
94
95             "DELETE" will flag the message to be deleted in case of a match.
96             When a multipart's part is matched, the whole message will be
97             flagged for deletion.
98
99           field => undef|STRING|REGEX|CODE
100             Not valid in combination with "in" set to "BODY".  The STRING is
101             one full field name (case-insensitive).  Use a REGEX to select
102             more than one header line to be scanned. CODE is a routine which
103             is called for each field in the header.   The CODE is called with
104             the header as first, and the field as second argument.  If the
105             CODE returns true, the message is selected.
106
107           in => 'HEAD'|'BODY'|'MESSAGE'
108           label => STRING
109           limit => NUMBER
110           log => LEVEL
111           logical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'
112           match => STRING|REGEX|CODE
113             The pattern to be search for can be a REGular EXpression, or a
114             STRING.  In both cases, the match succeeds if it is found
115             anywhere within the selected fields.
116
117             With a CODE reference, that function will be called each field or
118             body-line.  When the result is true, the details are delivered.
119             The call formats are
120
121              $code->($head, $field);          # for HEAD searches
122              $code->($body, $linenr, $line);  # for BODY searches
123
124             The $head resp $body are one message's head resp. body object.
125             The $field is a header line which matches.  The $line and $linenr
126             tell the matching line in the body.
127
128             Be warned that when you search in "MESSAGE" the code must accept
129             both formats.
130
131           multiparts => BOOLEAN
132           trace => LEVEL
133
134   Searching
135       Extends "Searching" in Mail::Box::Search.
136
137       $obj->inBody($part, $body)
138           Inherited, see "Searching" in Mail::Box::Search
139
140       $obj->inHead($part, $head)
141           Inherited, see "Searching" in Mail::Box::Search
142
143       $obj->search($folder|$thread|$message|ARRAY)
144           Inherited, see "Searching" in Mail::Box::Search
145
146       $obj->searchPart($part)
147           Inherited, see "Searching" in Mail::Box::Search
148
149   The Results
150       Extends "The Results" in Mail::Box::Search.
151
152       $obj->printMatch( [$fh], $match )
153       $obj->printMatchedBody($fh, $match)
154       $obj->printMatchedHead($fh, $match)
155
156   Error handling
157       Extends "Error handling" in Mail::Box::Search.
158
159       $obj->AUTOLOAD()
160           Inherited, see "Error handling" in Mail::Reporter
161
162       $obj->addReport($object)
163           Inherited, see "Error handling" in Mail::Reporter
164
165       $obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level,
166       $callback] )
167       Mail::Box::Search::Grep->defaultTrace( [$level]|[$loglevel,
168       $tracelevel]|[$level, $callback] )
169           Inherited, see "Error handling" in Mail::Reporter
170
171       $obj->errors()
172           Inherited, see "Error handling" in Mail::Reporter
173
174       $obj->log( [$level, [$strings]] )
175       Mail::Box::Search::Grep->log( [$level, [$strings]] )
176           Inherited, see "Error handling" in Mail::Reporter
177
178       $obj->logPriority($level)
179       Mail::Box::Search::Grep->logPriority($level)
180           Inherited, see "Error handling" in Mail::Reporter
181
182       $obj->logSettings()
183           Inherited, see "Error handling" in Mail::Reporter
184
185       $obj->notImplemented()
186           Inherited, see "Error handling" in Mail::Reporter
187
188       $obj->report( [$level] )
189           Inherited, see "Error handling" in Mail::Reporter
190
191       $obj->reportAll( [$level] )
192           Inherited, see "Error handling" in Mail::Reporter
193
194       $obj->trace( [$level] )
195           Inherited, see "Error handling" in Mail::Reporter
196
197       $obj->warnings()
198           Inherited, see "Error handling" in Mail::Reporter
199
200   Cleanup
201       Extends "Cleanup" in Mail::Box::Search.
202
203       $obj->DESTROY()
204           Inherited, see "Cleanup" in Mail::Reporter
205

DIAGNOSTICS

207       Error: Package $package does not implement $method.
208           Fatal error: the specific package (or one of its superclasses) does
209           not implement this method where it should. This message means that
210           some other related classes do implement this method however the
211           class at hand does not.  Probably you should investigate this and
212           probably inform the author of the package.
213

SEE ALSO

215       This module is part of Mail-Box distribution version 3.008, built on
216       October 04, 2019. Website: http://perl.overmeer.net/CPAN/
217

LICENSE

219       Copyrights 2001-2019 by [Mark Overmeer]. For other contributors see
220       ChangeLog.
221
222       This program is free software; you can redistribute it and/or modify it
223       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
224
225
226
227perl v5.30.1                      2020-01-30        Mail::Box::Search::Grep(3)
Impressum