Modifying MIME components with MIME-Tools is not at all impossible - Although I cannot copy and paste code directly from existing code in which I have implemented this functionality using MIME-Tools (as it corporate code), I should be able to provide some example code (see below) to help you in your task.

# The variable $entity contains a MIME::Entity object returned from +MIME::Parser # and from this object, a MIME::Body object is retrieved for content + manipulation. my $body = $entity->body; my $content = $body->as_string; # The content of the MIME component can now be modified as you see f +it $content =~ s/foo/bar/g; # The updated content must now be written back into the MIME message + component - # This is performed through manipulation of the MIME::Body object. my $io = $body->open('w'); $io->print( $content ) $io->close; # At this point, you may need to re-synchronise the headers of the M +IME::Entity # object - This method will add or update a Content-Length header wi +thin the # MIME component. $entity->sync_headers( 'Length' => 'COMPUTE', 'Nonstandard' => 'ERASE' );

 

perl -le "print unpack'N', pack'B32', '00000000000000000000001011110000'"


In reply to Re: Modifying MIME messages with MIME-Tools by rob_au
in thread Modifying MIME messages with MIME-Tools by skazat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.