| 1 |
NAME |
| 2 |
Text::Quoted - Extract the structure of a quoted mail message |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Text::Quoted; |
| 6 |
my $structure = extract($text); |
| 7 |
|
| 8 |
# Optionally, customize recognized quote characters: |
| 9 |
Text::Quoted::set_quote_characters( qr/[:]/ ); |
| 10 |
|
| 11 |
DESCRIPTION |
| 12 |
"Text::Quoted" examines the structure of some text which may contain |
| 13 |
multiple different levels of quoting, and turns the text into a nested |
| 14 |
data structure. |
| 15 |
|
| 16 |
The structure is an array reference containing hash references for each |
| 17 |
paragraph belonging to the same author. Each level of quoting |
| 18 |
recursively adds another list reference. So for instance, this: |
| 19 |
|
| 20 |
> foo |
| 21 |
> # Bar |
| 22 |
> baz |
| 23 |
|
| 24 |
quux |
| 25 |
|
| 26 |
turns into: |
| 27 |
|
| 28 |
[ |
| 29 |
[ |
| 30 |
{ text => 'foo', quoter => '>', raw => '> foo' }, |
| 31 |
[ |
| 32 |
{ text => 'Bar', quoter => '> #', raw => '> # Bar' } |
| 33 |
], |
| 34 |
{ text => 'baz', quoter => '>', raw => '> baz' } |
| 35 |
], |
| 36 |
|
| 37 |
{ empty => 1 }, |
| 38 |
{ text => 'quux', quoter => '', raw => 'quux' } |
| 39 |
]; |
| 40 |
|
| 41 |
This also tells you about what's in the hash references: "raw" is the |
| 42 |
paragraph of text as it appeared in the original input; "text" is what |
| 43 |
it looked like when we stripped off the quotation characters, and |
| 44 |
"quoter" is the quotation string. |
| 45 |
|
| 46 |
FUNCTIONS |
| 47 |
extract |
| 48 |
my $struct = extract($text, \%arg); |
| 49 |
|
| 50 |
Takes a single string argument which is the text to extract quote |
| 51 |
structure from. Returns a nested datastructure as described above. |
| 52 |
|
| 53 |
Second argument is optional: a hashref of options. The only valid |
| 54 |
argument at present is: |
| 55 |
|
| 56 |
no_separators - never mark paragraphs as "separators" |
| 57 |
|
| 58 |
Exported by default. |
| 59 |
|
| 60 |
set_quote_characters |
| 61 |
Takes a regex ("qr//") matching characters that should indicate a quoted |
| 62 |
line. By default, a very liberal set is used: |
| 63 |
|
| 64 |
set_quote_characters(qr/[!#%=|:]/); |
| 65 |
|
| 66 |
The character ">" is always recognized as a quoting character. |
| 67 |
|
| 68 |
If "undef" is provided instead of a regex, only ">" will remain as a |
| 69 |
quote character. |
| 70 |
|
| 71 |
Not exported by default, but exportable. |
| 72 |
|
| 73 |
combine_hunks |
| 74 |
my $text = combine_hunks( $arrayref_of_hunks ); |
| 75 |
|
| 76 |
Takes the output of "extract" and turns it back into text. |
| 77 |
|
| 78 |
Not exported by default, but exportable. |
| 79 |
|
| 80 |
CREDITS |
| 81 |
Most of the heavy lifting is done by a modified version of Damian |
| 82 |
Conway's "Text::Autoformat". |
| 83 |
|
| 84 |
AUTHOR |
| 85 |
Best Practical Solutions, LLC <[email protected]> |
| 86 |
|
| 87 |
LICENSE AND COPYRIGHT |
| 88 |
This software is Copyright (c) 2004-2015 by Best Practical Solutions, |
| 89 |
LLC |
| 90 |
|
| 91 |
This library is free software; you can redistribute it and/or modify it |
| 92 |
under the same terms as Perl itself. |
| 93 |
|