Text::Quoted - Extract the structure of a quoted mail message
use Text::Quoted; my $structure = extract($text);
Text::Quoted examines the structure of some text which may contain multiple different levels of quoting, and turns the text into a nested data structure.
Text::Quoted
The structure is an array reference containing hash references for each paragraph belonging to the same author. Each level of quoting recursively adds another list reference. So for instance, this:
> foo > # Bar > baz quux
turns into:
[ [ { text => 'foo', quoter => '>', raw => '> foo' }, [ { text => 'Bar', quoter => '> #', raw => '> # Bar' } ], { text => 'baz', quoter => '>', raw => '> baz' } ], { empty => 1 }, { text => 'quux', quoter => '', raw => 'quux' } ];
This also tells you about what's in the hash references: raw is the paragraph of text as it appeared in the original input; text is what it looked like when we stripped off the quotation characters, and quoter is the quotation string.
raw
text
quoter
Most of the heavy lifting is done by a modified version of Damian Conway's Text::Autoformat.
Text::Autoformat
Copyright (C) 2002 Kasei Limited
This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It may be used and redistributed under the terms of the Artistic License.
To install Text::Quoted, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Quoted
CPAN shell
perl -MCPAN -e shell install Text::Quoted
For more information on module installation, please visit the detailed CPAN module installation guide.