Destroying COM Objects

After you have finished using a Win32::OLE object, it needs to be destroyed. Destruction is accomplished in two ways: either by letting the object fall out of scope or by forcing it to destroy itself. Falling out of scope is quite easy; when the function, code block, or script terminates, the object is destroyed. Forcing the object to destroy itself requires that you call the object’s DESTROY() method:

$Object–>DESTROY(); 

This method takes no parameters and causes the object to terminate. Generally speaking, this method is used internally by the object itself and not by a Perl script.

It is possible that a script could run for hours but only need to create a COM object for just a few minutes. Assuming that for some reason ...

Get Win32 Perl Programming: The Standard Extensions, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.