On Jan 5, 7:00 pm, "jmcnamara" <jmcnam
...@cpan.org> wrote:
> I dug a little further into this and I think I see what is happening.
> The following is the sequence of events:
> * The program enters the eval block.
> * The new $workbook is created and scoped via my to the eval block.
> * The die() is called and $@ is set to the specified string.
> * The program exits the eval block.
> * The ref count for $workbook drops to 0.
> * The $workbook is garbage collected.
> * The Workbook DESTROY() method is called to close the excel file.
> * In one of the destructors an eval is used and $@ is reset to ''.
This is exactly correct.
The specific locations that clobber $@ during garbage-collection are as
follows:
1 - Format.pm lines 715 and 718 (two eval() statements, of which one
will be executed)
2 - "require Encode;" at line 493 of Workbook.pm
We're going to temporarily and internally solve this by doing the
following, until your next release is ready. While the below change
corrects the behavior, I'd very much welcome your feeling on the
approach. We're going to change in Workbook.pm:
sub DESTROY {
my $self = shift;
$self->close() if not $self->{_fileclosed};
}
to:
sub DESTROY {
my $self = shift;
my $dollar_at = $@ if $@;
$self->close() if not $self->{_fileclosed};
$@ = $dollar_at if $dollar_at;
}
> Probably not a very common situation but I'll fix it in the next
> release.
Thank you kindly, very much appreciated! Not common I agree, but when
it does occur, it can be extraordinarily nasty.