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
# and from this object, a MIME::Body object is retrieved for content
my $body = $entity->body;
my $content = $body->as_string;
# The content of the MIME component can now be modified as you see f
$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 )
# At this point, you may need to re-synchronise the headers of the M
# object - This method will add or update a Content-Length header wi
# MIME component.
'Length' => 'COMPUTE',
'Nonstandard' => 'ERASE'
perl -le "print unpack'N', pack'B32', '00000000000000000000001011110000'"