parsing a mbox file in PERL
parsing a mbox file in PERL
am 29.11.2007 01:46:46 von 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
--------------------------------------------------
All in all I'm just another brick in the FIREWALL.
Re: parsing a mbox file in PERL
am 29.11.2007 02:16:17 von Ben Morrow
Quoth Madhusudhanan Chandrasekaran :
>
> 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
Re: parsing a mbox file in PERL
am 29.11.2007 02:30:37 von Jim Gibson
In article ,
Madhusudhanan Chandrasekaran wrote:
> 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.
What versions are you running? Have you tried upgrading to the latest?
Lines 511-515 of Mail::MboxParser.pm are as follows:
if (! defined $Parser) {
eval { require MIME::Parser; };
$Parser = new MIME::Parser; $Parser->output_to_core(1);
$Parser->extract_uuencode($self->{ARGS}->{uudecode});
}
.... and it looks like the code is not checking if the "require
MIME::Parser" worked :^(
Make sure MIME::Parser is installed properly. Try putting
warn("No MIME::Parser $@") if $@;
after the eval.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Re: parsing a mbox file in PERL
am 29.11.2007 03:11:46 von 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
On Wed, 28 Nov 2007, Jim Gibson wrote:
> In article ,
> Madhusudhanan Chandrasekaran wrote:
>
> > 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.
>
> What versions are you running? Have you tried upgrading to the latest?
>
> Lines 511-515 of Mail::MboxParser.pm are as follows:
>
>
> if (! defined $Parser) {
> eval { require MIME::Parser; };
> $Parser = new MIME::Parser; $Parser->output_to_core(1);
> $Parser->extract_uuencode($self->{ARGS}->{uudecode});
> }
>
> ... and it looks like the code is not checking if the "require
> MIME::Parser" worked :^(
>
> Make sure MIME::Parser is installed properly. Try putting
>
> warn("No MIME::Parser $@") if $@;
>
> after the eval.
>
> --
> Jim Gibson
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com
>
--------------------------------------------------
All in all I'm just another brick in the FIREWALL.
Re: parsing a mbox file in PERL
am 29.11.2007 04:25:35 von Ben Morrow
[quoting fixed. please don't top-post]
Quoth Madhusudhanan Chandrasekaran :
> On Wed, 28 Nov 2007, Jim Gibson wrote:
> > In article ,
> > Madhusudhanan Chandrasekaran wrote:
> > >
> > > 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.
> >
> > Lines 511-515 of Mail::MboxParser.pm are as follows:
> >
> >
> > ... and it looks like the code is not checking if the "require
> > MIME::Parser" worked :^(
> >
> > Make sure MIME::Parser is installed properly. Try putting
> >
> > warn("No MIME::Parser $@") if $@;
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.
> > after the eval.
>
> 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