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

View: New views
2 Messages — Rating Filter:   Alert me  

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

by Tim Bruijnzeels :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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++;
    }
  }

I have found some conflicting info about the actual splitting
procedure.. specifically whether I should use: $message->body->parts, or
$message->parts or $message->parts() is not entirely clear to me. But
the error is the same in all cases.

In any case what's more confusing to me is that as far as I can tell my
code is not causing this error (though I won't say it couldn't be). The
$message object is defined, it tells me it's multipart, but as soon as I
try to split it, it barfs. The undefined value seems to be in
Mail/Box/File/Message somewhere, or somewhere else in Mail::Box.. but my
knowledge about its internals is very, very limited. Any ideas about
what's causing this?

MailBox 2.063, installed through CPAN today. On a RedHat Enterprise
Linux 4 system.

Regards,

Tim Bruijnzeels



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

by Tim Bruijnzeels :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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






LightInTheBox - Buy quality products at wholesale price!