in reply to Modifying MIME messages with MIME-Tools
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'"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Modifying MIME messages with MIME-Tools
by skazat (Chaplain) on Nov 09, 2004 at 22:06 UTC | |
Re^2: Modifying MIME messages with MIME-Tools
by skazat (Chaplain) on Nov 09, 2004 at 22:13 UTC |
In Section
Seekers of Perl Wisdom