in reply to Trying to correctly parse MIME
I have downloaded your files and had a play. First of all your script is not terribly informative. I was debugging at around line 16 and I think at this stage you find it helpful to add this there:
This shows that if you remove the initial empty line at the start of the email file it at least it picks up the headers. Did you try debugging the code and using the various as_string methods in MIME::Tools to get more insight into what is happening?
die "empty header" if !$header;