Re: Mail::Box error? Processing multipart message read from mbox

Tim Bruijnzeels <[email protected]> Mon, 23 Jan 2006 15:53:25 +0100
Newsgroups gmane.comp.lang.perl.modules.mail-box
Message-ID <[email protected]>
Hi all,

in answer to my own message:

Tim Bruijnzeels wrote:
> Hi,
> 
> I keep running into the following error when processing a multipart message:
> 
> Can't call method "parser" on an undefined value at
> /usr/lib/perl5/site_perl/5.8.5/Mail/Box/File/Message.pm line 93.
> 
> I am trying, well succeeding til I hit that error, to read an mbox. The
> relevant code in my script:
> 
>   if ($message->isMultipart) {
>     debug("message is multipart, getting them..");
>     my Mail::Message::Part $part;
>     my $i = 1;
>     foreach $part ($message->body->parts) {
>       debug("processing part $i");
>       $body .= parse_message($part, $config_hash_ref);
>       $i++;
>     }
>   }

As it turns out the problem _was_ related to other parts of my code..

Basically the problem was I created a sub that instantiated a
Mail::Box::Manager object, put all message objects in an array, closed
the Mail::Box::Manager object and returned the array.

When accessing the message objects in this array later, their folder
objects were undefined, presumably deleted by Mail::Box::Manager's
destroy method.

If this is the cause I can see why it makes sense, though I would prefer
if I were able to do this; I don't like globals, nor supersubs.

Cheers,
Tim