I am developing a script for parsing email attachments with XML data in them. The script runs just fine when there is only one message in the inbox but breaks when there is more than one. The error message is as follows:</>

Can't call method "XMLin" on unblessed reference at new_test.pl line 126.

As can be seen in the following code snippet, I have tried a couple of different things including using bless but I am not sure what the problem is.

foreach my $msgnum (keys %$msgnums) { print "Parsing email...\n"; #Get current messgae and create MIME object $lines = $pop3->get($msgnum); $current = join('', @$lines); $parsed = Email::MIME->new($current); #For each part in the message, extract the xml data foreach $part ($parsed->parts) { if (($part->{ct}->{discrete} eq 'application') && ($pa +rt->{ct}->{composite} eq 'plain')) { $xmlData = $part->body; #print $xmlData; #$xml = $xml->XMLin($xmlData); } } #For each extracted part of the xml data, parse the xml $xml = $xml->XMLin($xmlData); print "Component Data\n"; .... }

Any help would be greatly appreciated.


In reply to Unblessed Reference Error, XMLin by rdhoggan

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.