.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Mail::Box::Search::Grep 3pm" .TH Mail::Box::Search::Grep 3pm "2016-12-27" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mail::Box::Search::Grep \- select messages within a mail box like grep does .SH "INHERITANCE" .IX Header "INHERITANCE" .Vb 3 \& Mail::Box::Search::Grep \& is a Mail::Box::Search \& is a Mail::Reporter .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Mail::Box::Manager; \& my $mgr = Mail::Box::Manager\->new; \& my $folder = $mgr\->open(\*(AqInbox\*(Aq); \& \& my $filter = Mail::Box::Search::Grep\->new \& ( label => \*(Aqselected\*(Aq \& , in => \*(AqBODY\*(Aq, match => qr/abc?d*e/ \& ); \& \& my @msgs = $filter\->search($folder); \& \& my $filter = Mail::Box::Search::Grep\->new \& ( field => \*(AqTo\*(Aq \& , match => $my_email \& ); \& \& if($filter\->search($message)) {...} .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Try to find some text strings in the header and footer of messages. Various ways to limit the search to certain header fields, the whole header, only the body, the whole message, but even binary multiparts, are provided for. .PP The name \fIgrep\fR is derived from the \s-1UNIX\s0 tool \fIgrep\fR, which means: \*(L"Get Regular Expression and Print\*(R". Although you can search using regular expressions (the Perl way of them), you do not have to print those as result. .PP Extends \*(L"\s-1DESCRIPTION\*(R"\s0 in Mail::Box::Search. .SH "METHODS" .IX Header "METHODS" Extends \*(L"\s-1METHODS\*(R"\s0 in Mail::Box::Search. .SS "Constructors" .IX Subsection "Constructors" Extends \*(L"Constructors\*(R" in Mail::Box::Search. .IP "Mail::Box::Search::Grep\->\fBnew\fR(%options)" 4 .IX Item "Mail::Box::Search::Grep->new(%options)" Create a UNIX-grep like search filter. .Sp .Vb 10 \& \-Option \-\-Defined in \-\-Default \& binaries Mail::Box::Search \& decode Mail::Box::Search \& delayed Mail::Box::Search \& deleted Mail::Box::Search \& deliver undef \& field undef \& in Mail::Box::Search <$field ? \*(AqHEAD\*(Aq : C<\*(AqBODY\*(Aq>> \& label Mail::Box::Search undef \& limit Mail::Box::Search 0 \& log Mail::Reporter \*(AqWARNINGS\*(Aq \& logical Mail::Box::Search \*(AqREPLACE\*(Aq \& match \& multiparts Mail::Box::Search \& trace Mail::Reporter \*(AqWARNINGS\*(Aq .Ve .RS 4 .IP "binaries => \s-1BOOLEAN\s0" 2 .IX Item "binaries => BOOLEAN" .PD 0 .IP "decode => \s-1BOOLEAN\s0" 2 .IX Item "decode => BOOLEAN" .IP "delayed => \s-1BOOLEAN\s0" 2 .IX Item "delayed => BOOLEAN" .IP "deleted => \s-1BOOLEAN\s0" 2 .IX Item "deleted => BOOLEAN" .IP "deliver => undef|CODE|'\s-1DELETE\s0'|LABEL|'\s-1PRINT\s0'|REF\-ARRAY" 2 .IX Item "deliver => undef|CODE|'DELETE'|LABEL|'PRINT'|REF-ARRAY" .PD Store the details about where the match was found. The search may take much longer when this feature is enabled. .Sp When an \s-1ARRAY\s0 is specified it will contain a list of references to hashes. Each hash contains the information of one match. A match in a header line will result in a line with fields \f(CW\*(C`message\*(C'\fR, \f(CW\*(C`part\*(C'\fR, and \f(CW\*(C`field\*(C'\fR, where the field is a Mail::Message::Field object. When the match is in the body the hash will contain a \f(CW\*(C`message\*(C'\fR, \f(CW\*(C`part\*(C'\fR, \f(CW\*(C`linenr\*(C'\fR, and \f(CW\*(C`line\*(C'\fR. .Sp In case of a \s-1CODE\s0 reference, that routine is called for each match. The first argument is this search object and the second a reference to same hash as would be stored in the array. .Sp The \f(CW\*(C`PRINT\*(C'\fR will call \fIprintMatchedHead()\fR or \fIprintMatchedBody()\fR when any matching header resp body line was found. The output is minimized by not reprinting the message info on multiple matches in the same message. .Sp \&\f(CW\*(C`DELETE\*(C'\fR will flag the message to be deleted in case of a match. When a multipart's part is matched, the whole message will be flagged for deletion. .IP "field => undef|STRING|REGEX|CODE" 2 .IX Item "field => undef|STRING|REGEX|CODE" Not valid in combination with \f(CW\*(C`in\*(C'\fR set to \f(CW\*(C`BODY\*(C'\fR. The \s-1STRING\s0 is one full field name (case-insensitive). Use a \s-1REGEX\s0 to select more than one header line to be scanned. \s-1CODE\s0 is a routine which is called for each field in the header. The \s-1CODE\s0 is called with the header as first, and the field as second argument. If the \s-1CODE\s0 returns true, the message is selected. .IP "in => '\s-1HEAD\s0'|'\s-1BODY\s0'|'\s-1MESSAGE\s0'" 2 .IX Item "in => 'HEAD'|'BODY'|'MESSAGE'" .PD 0 .IP "label => \s-1STRING\s0" 2 .IX Item "label => STRING" .IP "limit => \s-1NUMBER\s0" 2 .IX Item "limit => NUMBER" .IP "log => \s-1LEVEL\s0" 2 .IX Item "log => LEVEL" .IP "logical => '\s-1REPLACE\s0'|'\s-1AND\s0'|'\s-1OR\s0'|'\s-1NOT\s0'|'\s-1AND NOT\s0'|'\s-1OR NOT\s0'" 2 .IX Item "logical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'" .IP "match => STRING|REGEX|CODE" 2 .IX Item "match => STRING|REGEX|CODE" .PD The pattern to be search for can be a REGular EXpression, or a \s-1STRING. \s0 In both cases, the match succeeds if it is found anywhere within the selected fields. .Sp With a \s-1CODE\s0 reference, that function will be called each field or body-line. When the result is true, the details are delivered. The call formats are .Sp .Vb 2 \& $code\->($head, $field); # for HEAD searches \& $code\->($body, $linenr, $line); # for BODY searches .Ve .Sp The \f(CW$head\fR resp \f(CW$body\fR are one message's head resp. body object. The \&\f(CW$field\fR is a header line which matches. The \f(CW$line\fR and \f(CW$linenr\fR tell the matching line in the body. .Sp Be warned that when you search in \f(CW\*(C`MESSAGE\*(C'\fR the code must accept both formats. .IP "multiparts => \s-1BOOLEAN\s0" 2 .IX Item "multiparts => BOOLEAN" .PD 0 .IP "trace => \s-1LEVEL\s0" 2 .IX Item "trace => LEVEL" .RE .RS 4 .RE .PD .SS "Searching" .IX Subsection "Searching" Extends \*(L"Searching\*(R" in Mail::Box::Search. .ie n .IP "$obj\->\fBinBody\fR($part, $body)" 4 .el .IP "\f(CW$obj\fR\->\fBinBody\fR($part, \f(CW$body\fR)" 4 .IX Item "$obj->inBody($part, $body)" Inherited, see \*(L"Searching\*(R" in Mail::Box::Search .ie n .IP "$obj\->\fBinHead\fR($part, $head)" 4 .el .IP "\f(CW$obj\fR\->\fBinHead\fR($part, \f(CW$head\fR)" 4 .IX Item "$obj->inHead($part, $head)" Inherited, see \*(L"Searching\*(R" in Mail::Box::Search .ie n .IP "$obj\->\fBsearch\fR($folder|$thread|$message|ARRAY)" 4 .el .IP "\f(CW$obj\fR\->\fBsearch\fR($folder|$thread|$message|ARRAY)" 4 .IX Item "$obj->search($folder|$thread|$message|ARRAY)" Inherited, see \*(L"Searching\*(R" in Mail::Box::Search .ie n .IP "$obj\->\fBsearchPart\fR($part)" 4 .el .IP "\f(CW$obj\fR\->\fBsearchPart\fR($part)" 4 .IX Item "$obj->searchPart($part)" Inherited, see \*(L"Searching\*(R" in Mail::Box::Search .SS "The Results" .IX Subsection "The Results" Extends \*(L"The Results\*(R" in Mail::Box::Search. .ie n .IP "$obj\->\fBprintMatch\fR( [$fh], $match )" 4 .el .IP "\f(CW$obj\fR\->\fBprintMatch\fR( [$fh], \f(CW$match\fR )" 4 .IX Item "$obj->printMatch( [$fh], $match )" .PD 0 .ie n .IP "$obj\->\fBprintMatchedBody\fR($fh, $match)" 4 .el .IP "\f(CW$obj\fR\->\fBprintMatchedBody\fR($fh, \f(CW$match\fR)" 4 .IX Item "$obj->printMatchedBody($fh, $match)" .ie n .IP "$obj\->\fBprintMatchedHead\fR($fh, $match)" 4 .el .IP "\f(CW$obj\fR\->\fBprintMatchedHead\fR($fh, \f(CW$match\fR)" 4 .IX Item "$obj->printMatchedHead($fh, $match)" .PD .SS "Error handling" .IX Subsection "Error handling" Extends \*(L"Error handling\*(R" in Mail::Box::Search. .ie n .IP "$obj\->\fB\s-1AUTOLOAD\s0\fR()" 4 .el .IP "\f(CW$obj\fR\->\fB\s-1AUTOLOAD\s0\fR()" 4 .IX Item "$obj->AUTOLOAD()" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBaddReport\fR($object)" 4 .el .IP "\f(CW$obj\fR\->\fBaddReport\fR($object)" 4 .IX Item "$obj->addReport($object)" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBdefaultTrace\fR( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )" 4 .el .IP "\f(CW$obj\fR\->\fBdefaultTrace\fR( [$level]|[$loglevel, \f(CW$tracelevel\fR]|[$level, \f(CW$callback\fR] )" 4 .IX Item "$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )" .PD 0 .ie n .IP "Mail::Box::Search::Grep\->\fBdefaultTrace\fR( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )" 4 .el .IP "Mail::Box::Search::Grep\->\fBdefaultTrace\fR( [$level]|[$loglevel, \f(CW$tracelevel\fR]|[$level, \f(CW$callback\fR] )" 4 .IX Item "Mail::Box::Search::Grep->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )" .PD Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBerrors\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBerrors\fR()" 4 .IX Item "$obj->errors()" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBlog\fR( [$level, [$strings]] )" 4 .el .IP "\f(CW$obj\fR\->\fBlog\fR( [$level, [$strings]] )" 4 .IX Item "$obj->log( [$level, [$strings]] )" .PD 0 .IP "Mail::Box::Search::Grep\->\fBlog\fR( [$level, [$strings]] )" 4 .IX Item "Mail::Box::Search::Grep->log( [$level, [$strings]] )" .PD Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBlogPriority\fR($level)" 4 .el .IP "\f(CW$obj\fR\->\fBlogPriority\fR($level)" 4 .IX Item "$obj->logPriority($level)" .PD 0 .IP "Mail::Box::Search::Grep\->\fBlogPriority\fR($level)" 4 .IX Item "Mail::Box::Search::Grep->logPriority($level)" .PD Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBlogSettings\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBlogSettings\fR()" 4 .IX Item "$obj->logSettings()" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBnotImplemented\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBnotImplemented\fR()" 4 .IX Item "$obj->notImplemented()" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBreport\fR( [$level] )" 4 .el .IP "\f(CW$obj\fR\->\fBreport\fR( [$level] )" 4 .IX Item "$obj->report( [$level] )" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBreportAll\fR( [$level] )" 4 .el .IP "\f(CW$obj\fR\->\fBreportAll\fR( [$level] )" 4 .IX Item "$obj->reportAll( [$level] )" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBtrace\fR( [$level] )" 4 .el .IP "\f(CW$obj\fR\->\fBtrace\fR( [$level] )" 4 .IX Item "$obj->trace( [$level] )" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .ie n .IP "$obj\->\fBwarnings\fR()" 4 .el .IP "\f(CW$obj\fR\->\fBwarnings\fR()" 4 .IX Item "$obj->warnings()" Inherited, see \*(L"Error handling\*(R" in Mail::Reporter .SS "Cleanup" .IX Subsection "Cleanup" Extends \*(L"Cleanup\*(R" in Mail::Box::Search. .ie n .IP "$obj\->\fB\s-1DESTROY\s0\fR()" 4 .el .IP "\f(CW$obj\fR\->\fB\s-1DESTROY\s0\fR()" 4 .IX Item "$obj->DESTROY()" Inherited, see \*(L"Cleanup\*(R" in Mail::Reporter .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .ie n .IP "Error: Package $package does not implement $method." 4 .el .IP "Error: Package \f(CW$package\fR does not implement \f(CW$method\fR." 4 .IX Item "Error: Package $package does not implement $method." Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. .SH "SEE ALSO" .IX Header "SEE ALSO" This module is part of Mail-Box distribution version 2.120, built on September 21, 2016. Website: \fIhttp://perl.overmeer.net/mailbox/\fR .SH "LICENSE" .IX Header "LICENSE" Copyrights 2001\-2016 by [Mark Overmeer]. For other contributors see ChangeLog. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR