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};
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.