mikeB has asked for the wisdom of the Perl Monks concerning the following question:
It seems Perl is cleaning up in "the wrong order" on my WinNT Perl 5.6.0 system. Below is a section of code from a module. The constructor creates a Win32::OLE object and stores a reference to it. When the destructor is called, that object is apparently already destroyed. I'm not sure how this can legitimately happen, as the module's instance data still holds a reference to the OLE object.
At the suggestion of someone in the CB (sorry... forgot who) I tried adding a global reference to the OLE object as an experiment to see if that would keep it around. That didn't seem to help.
What am I missing? Is there a way to make this work? Or am I barking up the wrong tree?
use Win32::OLE; sub new { # fileName my $self = {}; bless $self, shift; $self->{excel} = Win32::OLE->new("Excel.Application") or croak "Ca +n't start Excel: ", Win32::OLE->LastError, "\n"; return $self; } sub disconnect { my $self = shift; $self->{excel}->Quit if $self->{excel}; }
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re: non-deterministic destructors?
by tye (Sage) on Nov 10, 2001 at 00:18 UTC | |
by mikeB (Friar) on Nov 10, 2001 at 00:33 UTC | |
by tye (Sage) on Nov 10, 2001 at 01:20 UTC | |
Re: non-deterministic destructors?
by converter (Priest) on Nov 09, 2001 at 23:57 UTC |
Back to
Seekers of Perl Wisdom