Subject: | Email::Delete->delete_message(...) causes an error |
Summary
Using Email::Delete->delete_message(...) is broken. It can be fixed by
checking if the first argument to delete_message is a package name.
Details:
Normally delete_message is used like this:
use Email::Delete qw/delete_message/;
delete_message(
from => $mailbox,
matching => sub { 1; },
);
But if you use it like this:
use Email::Delete;
Email::Delete->delete_message(
from => $mailbox,
matching => sub { 1; },
);
Then it causes an error down the line. It's because the delete function
looks like:
sub delete_message {
my %args = @_;
In our use case, the first value in @_ is the package name, which is
given to %args as a key (which has the value "from"), screwing up the
whole order, and producing an uneven hash.
I think it can be fixed by adding this one line:
sub delete_message {
shift if $_[0] eq __PACKAGE__;
my %args = @_;
(Email-Delete-2.001, Perl 5.8.4, Linux 2.6.9)