Bug : Mail::Message::Head::FieldGroup::attach stringifies object
"Timur I. Bakeyev" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Message-ID | <[email protected]> |
Hi all!
I was trying to find out, why this documented piece of
code doesn't work:
my $sg = new Mail::Message::Head::SpamGroup(software =>
'MINE');
my $own_sg = $head->addSpamGroup($sg);
dying with the:
Can't use string ("Mail::Message::Head::SpamGroup") as a
HASH ref while "strict refs" in use at
/spool/timur/perllib/Mail/Message/Head/FieldGroup.pm line
56, <GEN0> line 163.
Bogus, isn't it?
So, after an hour with debugger it was tracked down to the
Mail::Message::Head::FieldGroup::attach method, which is
implemented like:
sub attach($)
{ my ($self, $head) = @_;
my $lg = ref($self)->clone;
$self->{MMHF_head} = $head;
$head->add($_->clone) for $self->fields;
$lg;
}
It seems, that taking ref($self) here is unnecessary :) At
least, that's the root of that evil stringification..
With regards,
Timur Bakeyev.