parsing a mbox file in PERL

  • Thread starter Madhusudhanan Chandrasekaran
  • Start date
M

Madhusudhanan Chandrasekaran

Hi,

I am trying to parse a mbox file and extract the message's
body. I am using Mail::MboxParser for this purpose. In my
source code, I have


my $mb = Mail::MboxParser->new('some_mailbox',
decode => 'ALL',
parseropts => $parseropts);

with the $parseropts initialized. However, it gives me the
following error message:

Can't locate object method "new" via package "MIME::parser" at
/usr/local/share/perl/5.8.8/Mail/MboxParser/Mail.pm line 513.

I've MIME::parser installed and it does seem to have a new method.

Any pointers appreciated.

Thanks in advance,

_Madhu
 
B

Ben Morrow

Quoth Madhusudhanan Chandrasekaran said:
I am trying to parse a mbox file and extract the message's
body. I am using Mail::MboxParser for this purpose. In my
source code, I have

my $mb = Mail::MboxParser->new('some_mailbox',
decode => 'ALL',
parseropts => $parseropts);

with the $parseropts initialized. However, it gives me the
following error message:

Can't locate object method "new" via package "MIME::parser" at
/usr/local/share/perl/5.8.8/Mail/MboxParser/Mail.pm line 513.

I've MIME::parser installed and it does seem to have a new method.

Either you haven't, or perl's failing to find it. M::MbP::Mail requires
MIME::parser in an eval block, so you won't get an error if it can't be
found: not the most helpful thing to do. Try adding a

use MIME::parser;

line before your

use Mail::MboxParser;

line to get the error message earlier. Then work out why perl can't find
MIME::parser :).

Ben
 
M

Madhusudhanan Chandrasekaran

Thanks for the response. It's like pandoras box,
more emerge. I get the following message that
Mail::Header is missing. But I cannot install
it for some weird reason -- The exact error I get
is as:

/bin/tar: MailTools-2.01: time stamp 2007-11-28 04:48:57 is
253591.077197246 s in the future
Removing previously used /home/mc79/.cpan/build/MailTools-2.01

CPAN.pm: Going to build M/MA/MARKOV/MailTools-2.01.tar.gz

WARNING: LICENSE is not a known parameter.
Checking if your kit is complete...
Looks good
'LICENSE' is not a known MakeMaker parameter name.
Writing Makefile for Mail
make: Warning: File `Makefile.PL' has modification time 2.5e+05 s in the
future
Makefile out-of-date with respect to Makefile.PL
Cleaning current config before rebuilding Makefile...
/usr/bin/make -f Makefile.old clean > /dev/null 2>&1
/usr/bin/perl Makefile.PL "INSTALLDIRS=site"
WARNING: LICENSE is not a known parameter.
Checking if your kit is complete...
Looks good
'LICENSE' is not a known MakeMaker parameter name.
Writing Makefile for Mail
==> Your Makefile has been rebuilt. <==
==> Please rerun the /usr/bin/make command. <==
false
make: *** [Makefile] Error 1
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible



How would one get around these?

Thanks,
_Madhu
 
B

Ben Morrow

[quoting fixed. please don't top-post]


This isn't in general a very safe construction. There are too many ways
(destructors, signal handlers, etc.) in which $@ can get messed up.
Better is to make sure the eval returns true, and test for that:

eval {
require MIME::parser;
1; # 5.8.0 has a bug where require in eval can return false
} or warn "No MIME::parser: $@";

Of course, if something untoward happens the error message will be
wrong, but that's better than failing to catch the error at all.
Thanks for the response. It's like pandoras box,
more emerge. I get the following message that
Mail::Header is missing. But I cannot install
it for some weird reason -- The exact error I get
is as:

/bin/tar: MailTools-2.01: time stamp 2007-11-28 04:48:57 is
253591.077197246 s in the future

Your computer's clock is wrong. make depends on having the clock at
least approximately right, so you will need to fix this.

==> Your Makefile has been rebuilt. <==
==> Please rerun the /usr/bin/make command. <==
false

MakeMaker is asking you to re-run make: if you do, it's possible it will
work correctly this time. It's probably better to fix your clock,
though.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top