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};
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|