Skip Menu |

This queue is for tickets about the MIME-Lite CPAN distribution.

Report information
The Basics
Id: 29611
Status: resolved
Priority: 0/
Queue: MIME-Lite

People
Owner: Nobody in particular
Requestors: awk [...] bnt.com
Cc:
AdminCc:

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



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?)
That addition certainly seems unneeded, but since it's been out for a while and I don't know why it was added, I have instead fixed it. That means that arrays and hashes are only unfolded if they would be the "value" in a pair. So, given: ( $a => $b, $c => \%d, \@e, $f => \@g, \%h) only @e and %h should be unfolded sigh -- rjbs