Hi all,

I have no experience parsing MIME encoded messages, so forgive my noobness here. I'm looking to find out if this is expected behavior given the input, hopefully somebody has the experience to help out.

First up, this is the input data, I've taken out most of the context sensitive stuff, but basically this is a response I get from an API:

--MIMEBoundaryurn_uuid_5922B37D7F43649CB512578951566415053 Content-Type: application/xop+xml; charset=utf-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: <0.urn:uuid:5922B37D7F43649CB512578951566415054> <XML RESPONSE GOES HERE> --MIMEBoundaryurn_uuid_5922B37D7F43649CB512578951566415053 Content-Type: application/zip Content-Transfer-Encoding: binary Content-ID: <urn:uuid:A86D19E1CDE87B2FD01257895160515> ^_~K^H^H­>üJ^@^Ctest^@^C^@^@^@^@^@^@^@^@^@ --MIMEBoundaryurn_uuid_5922B37D7F43649CB512578951566415053--

So basically this message is supposed to contain a XML response section, followed by a Binary file, in this case it is a gziped file. I replaced the gzip file with an empty gzip file for space, and removed the acutal XML response, but I think the problem might just be how the MIME is structured?

No knowing much else, this is the code I have tried to use to parse out the two entities, but all I get is a single text/plain entity, which contains as it's body text, everything from the XML code start down (including all the MIME tags below the XML code). Any ideas on how to slice this?

Code so far

my $parser = new MIME::Parser (); my $ent = $parser->parse_open ($response_file); $ent->dump_skeleton; print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; print $ent->stringify_body;

And the output:

Content-type: text/plain Effective-type: text/plain Body-file: ./msg-11891-1.txt -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <XML RESPONSE GOES HERE> --MIMEBoundaryurn_uuid_5922B37D7F43649CB512578951566415053 Content-Type: application/zip Content-Transfer-Encoding: binary Content-ID: <urn:uuid:A86D19E1CDE87B2FD01257895160515> ^_~K^H^H­>üJ^@^Ctest^@^C^@^@^@^@^@^@^@^@^@ --MIMEBoundaryurn_uuid_5922B37D7F43649CB512578951566415053--
So if I understand this right, it did not read in two entities but just one, again I wonder if the MIME is correct.

In reply to Help on Parsing MIME by fert

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.