Subject: | MIME-Lite-3.020 breaks send_by_sendmail handling of BaseArgs |
Date: | Tue, 25 Sep 2007 21:29:50 -0400 |
To: | bug-MIME-Lite [...] rt.cpan.org |
From: | awk <awk [...] bnt.com> |
Specifically, the array ref value for BaseArgs gets derefenced and mixed in
with the other arguments. For example, the following code:
###########################################################################
use MIME::Lite;
$m = MIME::Lite->new(
From => 'me@mydomain.com',
To => 'you@yourdomain.com',
Subject => 'Test Message',
Data => 'Testing 123.',
);
$m->send_by_sendmail(BaseArgs => [ '-t', '-oi', '-oem' ]);
###########################################################################
Dies with the following error:
Can't use string ("-t") as an ARRAY ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5.8.8/MIME/Lite.pm line 2685.
This is because some newly added code at line #2677 steps through each element
of @_ and derefences it. Basically, it turns this:
( BaseArgs => [ '-t', '-oi', '-oem' ] )
into this:
( BaseArgs => '-t', '-oi' => '-oem' )
I fixed the problem by adding braces around the arguments, like this:
$m->send_by_sendmail( { BaseArgs => [ '-t', '-oi', '-oem' ] } );
However, this breaks compatibility with the older version of MIME::Lite I
upgraded from. It would be nice to fix this so the old syntax works on both
versions. Something like this perhaps:
%p = (@_==1 && UNIVERSAL::isa($_[0], 'HASH')) ? %{$_[0]} : @_;
(Is there really a need for handling array refs?)