MIME::BodyMunger - rewrite the content of text parts, minding charset
version 0.007
MIME::BodyMunger->rewrite_content( $mime_entity, sub { my ($body_ref) = @_; $$body_ref =~ s/zig/zag/; }, );
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.
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
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.
MIME::BodyMunger->rewrite_lines($message, sub { ... });
This method behaves like rewrite_content, but the callback is invoked once per line, like this:
rewrite_content
local $_ = $line; $code->($message);
If any line is changed, the entire body will be reencoded and updated.
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.
Ricardo SIGNES <cpan@semiotic.systems>
Brian Cassidy <bricas@bricas-laptop.(none)>
Ricardo Signes <rjbs@semiotic.systems>
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.
To install MIME::BodyMunger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MIME::BodyMunger
CPAN shell
perl -MCPAN -e shell install MIME::BodyMunger
For more information on module installation, please visit the detailed CPAN module installation guide.