NAME
MIME::BodyMunger - rewrite the content of text parts, minding charset
VERSION
version 0.005
SYNOPSIS
MIME::BodyMunger->rewrite_content(
$mime_entity,
sub {
my ($body_ref) = @_;
$$body_ref =~ s/zig/zag/;
},
);
DESCRIPTION
MIME::BodyMunger provides methods for rewriting text parts. These methods take care of character sets for you so that you can treat everything like text instead of worrying about content transfer encoding or character set encoding.
At present, only MIME::Entity messages can be handled. Other types will be added in the future.
METHODS
rewrite_content
MIME::BodyMunger->rewrite_content($message, sub { ... });
This method uses the given callback to rewrite the content (body) of the message. It decodes the content (using Content-Transfer-Encoding and the Content-Type charset (or ISO-8859-1, if none is given)) and provides a reference to the character string to the coderef. If the content is altered, the body will be re-encoded into the original charset and the message will be updated.
The callback is invoked like this:
$code->(\$content, $message);
In the future, there should be an option to re-encode to an alternate charset.
rewrite_lines
MIME::BodyMunger->rewrite_lines($message, sub { ... });
This method behaves like rewrite_content
, but the callback is invoked once per line, like this:
local $_ = $line;
$code->($message);
If any line is changed, the entire body will be reencoded and updated.
THANKS
Thanks to Pobox.com and Listbox.com, who sponsored the development of this module.
Thanks to Brian Cassidy for writing some tests for the initial release.
AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.