Ricardo SIGNES > MIME-BodyMunger-0.004 > MIME::Visitor



Annotate this POD

View/Report Bugs
Module Version: 0.004   Source   Latest Release: MIME-BodyMunger-0.006


MIME::Visitor - walk through MIME parts and do stuff (like rewrite)


version 0.004


  # This will reverse all lines in each text part, taking care of all encoding
  # for you.

    sub { chomp; $_ = reverse . "\n"; },


MIME::Visitor provides a simple way to walk through the parts of a MIME message, taking action on each one. In general, this is not a very complicated thing to do, but having it in one place is convenient.

The most powerful feature of MIME::Visitor, though, is its 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.



  MIME::Visitor->walk_parts($root, sub { ... });

This method calls the given code on every part of the given root message, including the root itself.


  MIME::Visitor->walk_leaves($root, sub { ... });

This method calls the given code on every leaf part of the given root message. It descends into multipart parts of the message without calling the callback on them.


  MIME::Visitor->walk_text_leaves($root, sub { ... });

This method behaves like walk_leaves, but only calls the callback on parts with a content type of text/plain or text/html.


  MIME::Visitor->rewrite_parts($root, sub { ... });

This method walks the text leaves of the MIME message, rewriting the content of the parts. For each text leaf, the callback is invoked like this:

  $code->(\$content, $part);

For more information, see "rewrite_content" in MIME::BodyMunger.


  MIME::Visitor->rewrite_all_lines($root, sub { ... });

This method behaves like rewrite_parts, but the callback is called for each line of each relevant part, rather than for the part's body as a whole.


Ricardo SIGNES, <rjbs@cpan.org>


Thanks to Pobox.com and Listbox.com, who sponsored the development of this module.


Please report any bugs or feature requests through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Copyright 2008, Ricardo SIGNES. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: