Subject: | module says there is only one email, but there are two |
I attached an email folder with two emails in it. But when Mail::Mbox::MessageParser iterated through the emails in this folder, it has only one iteration. It should have two iterations since there are two emails.
A different module called Mail::Box::Manager correctly says there are two emails, so you might consider looking at Mail::Box::Manager to get an idea of how to fix Mail::Mbox::MessageParser. I can't just switch to Mail::Box::Manager since I am using grepmail and grepmail uses Mail::Mbox::MessageParser.
The attached email folder was made by the mail reader "VM" (http://www.wonderworks.com/vm/).
The perl script at the end of this report demonstrates the bug. The script uses example code from the documentation of each module. I made only small changes to the examples. The script outputs:
Mail::Mbox::MessageParser read an email.
Mail::Box::Manager says there are 2 emails.
But it should output:
Mail::Mbox::MessageParser read an email.
Mail::Mbox::MessageParser read an email.
Mail::Box::Manager says there are 2 emails.
"perl -v" says, "This is perl, v5.6.1 built for i386-linux".
"uname -a" says, "Linux sumatra.ca.metsci.com 2.4.18-17.7.xsmp #1 SMP Tue Oct 8 12:37:04 EDT 2002 i686 unknown".
Here are the versions of the perl modules:
Show quoted text
cpan> i Mail::Mbox::MessageParser
Strange distribution name [Mail::Mbox::MessageParser]
Module id = Mail::Mbox::MessageParser
CPAN_USERID DCOPPIT (David Coppit <david@coppit.org>)
CPAN_VERSION 1.3000
CPAN_FILE D/DC/DCOPPIT/Mail-Mbox-MessageParser-1.3000.tar.gz
INST_FILE (not installed)
Show quoted textcpan> i Mail::Box::Manager
Strange distribution name [Mail::Box::Manager]
Module id = Mail::Box::Manager
CPAN_USERID MARKOV (Mark Overmeer <mark@overmeer.net>)
CPAN_VERSION 2.060
CPAN_FILE M/MA/MARKOV/Mail-Box-2.060.tar.gz
MANPAGE Mail::Box::Manager - manage a set of folders
INST_FILE /usr/lib/perl5/site_perl/5.6.1/Mail/Box/Manager.pm
INST_VERSION 2.060
#!/usr/bin/perl -w
use strict;
use warnings;
use Mail::Mbox::MessageParser;
my $file_name = 'folder';
my $file_handle = new FileHandle($file_name);
# Set up cache. (Not necessary if enable_cache is false.)
Mail::Mbox::MessageParser::SETUP_CACHE(
{ 'file_name' => '/tmp/cache' } );
my $folder_reader =
new Mail::Mbox::MessageParser( {
'file_name' => $file_name,
'file_handle' => $file_handle,
'enable_cache' => 1,
'enable_grep' => 1,
} );
die $folder_reader unless ref $folder_reader;
# Any newlines or such before the start of the first email
my $prologue = $folder_reader->prologue;
print $prologue;
# This is the main loop. It's executed once for each email
while(!$folder_reader->end_of_file())
{
my $email = $folder_reader->read_next_email();
print "Mail::Mbox::MessageParser read an email.\n";
}
####################################################################
use Mail::Box::Manager;
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder => 'folder');
# Get the number of messages in scalar context.
my $emails = $folder->messages;
print "Mail::Box::Manager says there are $emails emails.\n";
Message body not shown because it is not plain text.