.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MboxParser::Mail::Body 3pm" .TH MboxParser::Mail::Body 3pm "2005-12-08" "perl v5.14.2" "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::MboxParser::Mail::Body \- rudimentary mail\-body object .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mail::MboxParser; \& \& [...] \& \& # $msg is a Mail::MboxParser::Mail \& my $body = $msg\->body(0); \& \& # or preferably \& \& my $body = $msg\->body($msg\->find_body); \& \& for my $line ($body\->signature) { print $line, "\en" } \& for my $url ($body\->extract_urls(unique => 1)) { \& print $url\->{url}, "\en"; \& print $url\->{context}, "\en"; \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class represents the body of an email-message. Since emails can have multiple MIME-parts and each of these parts has a body it is not always easy to say which part actually holds the text of the message (if there is any at all). Mail::MboxParser::Mail::find_body will help and suggest a part. .SH "METHODS" .IX Header "METHODS" .IP "\fBas_string ([strip_sig => 1])\fR" 4 .IX Item "as_string ([strip_sig => 1])" Returns the textual representation of the body as one string. Decoding takes place when the mailbox has been opened using the decode => '\s-1BODY\s0' | '\s-1ALL\s0' option. .Sp If 'strip_sig' is set to a true value, the signature is stripped from the string. .IP "\fBas_lines ([strip_sig => 1])\fR" 4 .IX Item "as_lines ([strip_sig => 1])" Sames as \fIas_string()\fR just that you get an array of lines with newlines attached to each line. .Sp \&\fB\s-1NOTE:\s0\fR When the body is actually some encoded binary data (most commonly such a body is base64\-encoded), you can still use this method. Then you wont really get proper lines. Instead you get chunks of binary data that you should concatenate as in .Sp .Vb 1 \& my $binary = join "", $body\->as_lines; .Ve .Sp If 'strip_sig' is set to a true value, the signature is stripped from the string. .IP "\fBsignature\fR" 4 .IX Item "signature" Returns the signature of a message as an array of lines. Trailing newlines are already removed. .Sp \&\f(CW$body\fR\->error returns a string if no signature has been found. .IP "\fBextract_urls\fR" 4 .IX Item "extract_urls" .PD 0 .IP "\fBextract_urls (unique => 1)\fR" 4 .IX Item "extract_urls (unique => 1)" .PD Returns an array of hash-refs. Each hash-ref has two fields: 'url' and \&'context' where context is the line in which the 'url' appeared. .Sp When calling it like \f(CW$mail\fR\->extract_urls(unique => 1), duplicate URLs will be filtered out regardless of the 'context'. That's useful if you just want a list of all URLs that can be found in your mails. .Sp \&\f(CW$body\fR\->\fIerror()\fR will return a string if no URLs could be found within the body. .IP "\fBquotes\fR" 4 .IX Item "quotes" Returns a hash-ref of array-refs where the hash-keys are the several levels of quotation. Each array-element contains the paragraphs of this quotation-level as one string. Example: .Sp .Vb 3 \& my $quotes = $msg\->body($msg\->find_body)\->quotes; \& print $quotes\->{1}\->[0], "\en"; \& print $quotes\->{0}\->[0], "\en"; .Ve .Sp This should print the first paragraph of the mail-body that has been quoted once and below that the paragraph that supposedly is the reply to this paragraph. Perhaps thus: .Sp .Vb 2 \& > I had been trying to work with the CGI module \& > but I didn\*(Aqt yet fully understand it. \& \& Ah, it is tricky. Have you read the CGI\-FAQ that \& comes with the module? .Ve .Sp Mark that empty lines will not be ignored and are part of the lines contained in the array of \f(CW$quotes\fR\->{0}. .Sp So below is a little code-snippet that should, in most cases, restore the first 5 paragraphs (containing quote-level 0 and 1) of an email: .Sp .Vb 4 \& for (0 .. 4) { \& print $quotes\->{0}\->[$_]; \& print $quotes\->{1}\->[$_]; \& } .Ve .Sp Since \fIquotes()\fR considers an empty line between two quotes paragraphs as a paragraph in \f(CW$quotes\fR\->{0}, the paragraphs with one quote and those with zero are balanced. That means: .Sp scalar @{$quotes\->{0}} \- \s-1DIFF\s0 == scalar @{$quotes\->{1}} where \s-1DIFF\s0 is element of {\-1, 0, 1}. .Sp Unfortunately, \fIquotes()\fR can up to now only deal with '>' as quotation-marks. .SH "VERSION" .IX Header "VERSION" This is version 0.55. .SH "AUTHOR AND COPYRIGHT" .IX Header "AUTHOR AND COPYRIGHT" Tassilo von Parseval .PP Copyright (c) 2001\-2005 Tassilo von Parseval. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO"