Uninitialized value warning when deleting POP3 message
"David Phillips" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <000701c3e416$aea68d30$2100a8c0@tweezerman> |
I have a script running as a cron job that read messages from a POP3 server, processes them for posting to a weblog, then deletes the message from the POP3 server. This is the code I'm using to open the POP3 folder:
use Mail::Box::Manager;
# prepare the POP account
my $mgr = Mail::Box::Manager->new;
my $folder = $mgr->open(folder=>'popmail',
type=>'pop3',
username=>$popuser,
password=>$poppass,
server_name=>$popsite,
access=>'rw',
log=>'ERRORS');
After the folder is open, it goes through each message:
foreach my $message ($folder->messages) {
...
<read and process each message>
...
$message->delete;
}
$folder->close(write => 'NEVER'); #close POP without a local store
When a message is deleted, cron e-mails me the following warning:
Use of uninitialized value in numeric ne (!=)
at /usr/lib/perl5/site_perl/5.6.1/Mail/Box/POP3/Message.pm line 47
This is the code from Mail/Box/POP3/Message.pm where the warning occurs - it occurs when "if $newdel != $olddel;" is evaluated:
sub label(@)
{ my $self = shift;
$self->loadHead; # be sure the labels are read
return $self->SUPER::label(@_) if @_==1;
# POP3 can only set 'deleted' in the source folder. Don't forget
my $olddel = $self->label('deleted');
my $ret = $self->SUPER::label(@_);
my $newdel = $self->label('deleted');
$self->folder->popClient->deleted($newdel, $self->unique)
if $newdel != $olddel;
$ret;
}
Am I doing something wrong, or is this a problem with the Mail::Box::POP3 code? The messages are deleted properly - the warning is just annoying and I'd like to get rid of it. Currently I am suppressing the warning by using
#!/usr/bin/perl -X
...at the top of my script, but this seems like overkill to me.
If this is a problem with the Mail::Box::POP3 code, could code in my own script delete the messages safely without totally confusing Mail::Box?
David Phillips
[email protected]
http://tweezersedge.com/