in reply to Re^6: Is it possible to force MIME::Parser to extract text-files on a Windows system without the extra CR's on the end of lines?
in thread Is it possible to force MIME::Parser to extract text-files on a Windows system without the extra CR's on the end of lines?
Gotcha, yes, I dug around in the Parser.pm to have a look at that sort of stuff. For example, here is the part dealing with binary attachments:
$bin_ent->head->mime_attr('Content-type.x-unix-mode' => "0$mode"); $bin_ent->bodyhandle($self->new_body_for($bin_ent->head)); $bin_ent->bodyhandle->binmode(1) or die "$ME: can't set to binmode: $! +"; my $io = $bin_ent->bodyhandle->open("w") or die "$ME: can't create: $! +"; $io->print($bin_data) or die "$ME: can't print: $!"; $io->close or die "$ME: can't close: $!";
And here is the part dealing with text attachments:
$txt_ent->bodyhandle($self->new_body_for($txt_ent->head)); my $io = $txt_ent->bodyhandle->open("w") or die "$ME: can't create: $! +"; $io->print(@$preamble) or die "$ME: can't print: $!"; $io->close or die "$ME: can't close: $!";
So it occurred to me: "Hmm! If I add in code to force the text to use binary like this..."
$txt_ent->bodyhandle($self->new_body_for($txt_ent->head)); $txt_ent->bodyhandle->binmode(1) or die "$ME: can't set to binmode: $! +"; my $io = $txt_ent->bodyhandle->open("w") or die "$ME: can't create: $! +";
Unfortunately it didn't work, leading me to conclude that I don't know enough about the code at this time to be dealing with changing the guts of an existing perl module.
Technically I could copy and recreate it under the name of MIME::MyParser and see if I could manage to hack that into submission - however it seemed more than I was capable of managing if I couldn't even change the existing code. It was at this point that I decided it was easier to hack the input-file to trick the parser into doing what I want it to do.
Cheers,
William
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Is it possible to force MIME::Parser to extract text-files on a Windows system without the extra CR's on the end of lines?
by Anonymous Monk on Feb 13, 2014 at 02:52 UTC |