Skip Menu |

This queue is for tickets about the Mail-Mbox-MessageParser CPAN distribution.

Report information
The Basics
Id: 43665
Status: resolved
Priority: 0/
Queue: Mail-Mbox-MessageParser

People
Owner: Nobody in particular
Requestors: dma [...] witbe.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Can't locate object method "end_of_file"
Date: Thu, 26 Feb 2009 17:14:15 +0100
To: bug-Mail-Mbox-MessageParser [...] rt.cpan.org
From: Daniel Maher <dma [...] witbe.net>
Mail-Mbox-MessageParser-1.5000 This is perl, v5.8.0 built for i386-linux-thread-multi Linux 2.6.14.4 #3 SMP Wed Dec 21 13:23:23 CET 2005 i686 Red Hat Enterprise Linux ES release 3 (Taroon) Can't locate object method "end_of_file" via package "No data on filehandle" (perhaps you forgot to load "No data on filehandle"?) at ./parse_mbox.pl line 40. #!/usr/bin/perl -wl use strict; use Mail::Mbox::MessageParser; my $inbox = "/var/spool/mail/bnpmail-internet"; my $handle = new FileHandle($inbox); my $reader = new Mail::Mbox::MessageParser( { 'file_name' => $inbox, 'file_handle' => $handle, 'enable_cache' => 0 } ); my $email; while ( ! $reader->end_of_file() ) { $email = $reader->read_next_email(); [perform a small action] } The error happens _sometimes_, but i've yet to figure out what causes it. Occasionally i will run the script over and over and it will happen 3 out of 4 times, and other times only sparingly. The quantity or type of mail in the inbox does not seem to affect it in any way.
You forget that an error message is returned if the mailbox cannot be opened correctly. See the synopsis in the documentation, which includes this line: die $folder_reader unless ref $folder_reader; What's happening is that your mailbox is periodically empty, so the module returns the error message "No data on filehandle". Then your code is trying to use the message like an object, so Perl complains. If you include the line above your code will exit with the "no data" error rather than getting the Perl error. Now, one could argue that this module should not return an error and instead just execute your loop 0 times. And I would agree. :) I've updated the module to use this new semantics instead. It will be changed in versions > 1.5001.