monarch has asked for the wisdom of the Perl Monks concerning the following question:

I am experiencing a long (approx 1 minute) delay when compiling or running a script that uses Win32::OLE::Const.

Running perl -wc mytest.pl takes approximately 1 minute 20 seconds to respond. My machine is a Hewlett-Packard WinXP professional running ActiveState Perl v5.8.7 with MSWin32-x86-multi-thread (Binary build 813). Pentium 4 2.8GHz, 504MB RAM.

During the delay there is almost no CPU being used.. so something could be blocking? Several months ago this would run with almost no delay. The script below compiles instantly when commenting out the line using Win32::OLE::Const.

Here is the code of mytest.pl:

use Win32::OLE; use Win32::OLE::Const 'Microsoft Office';

Update: searching through google offers this link to a cpan bug report which is identical to the problem I'm seeing.. Actually I think that bug report was the result of this perlmonks node. The fix reported works for me too, which is to remove the file-exists test in the _Typelib() function in Const.pm.

Replies are listed 'Best First'.
Re: Win32::OLE::Const startup delay
by spiritway (Vicar) on Mar 06, 2006 at 00:52 UTC

    Hi,[id://monarch]. I tried your script, and it compiled immediately, giving me a "syntax OK" message. I'm running the same version of Perl as you are, under XP Home, with a slower CPU but more memory. I'm having trouble imagining what might be causing the delay without burning cycles. Do you notice much disk activity? Do you have Microsoft products open that may somehow affect the script? Would there be any reason for something to time out, without showing any error?

    I suppose the next question is, what is different now, than was in effect several months ago? New software, updates of perl or modules, etc.?

      There's a line in:
      $PerlDir\site\lib\Win32\OLE\Const.pm
      that reads
      __PACKAGE__->_Typelibs;

      If I comment out this line then it loads instantly, if I uncomment this line, then I get my delay.

      Update: it appears that _Typelibs() is defined in

      site\lib\auto\Win32\OLE\OLE.dll
Re: Win32::OLE::Const startup delay
by Anonymous Monk on Mar 08, 2006 at 08:20 UTC
    I encountered the same problem in DBD::ADO::Const:
    It seems that all available type libraries are checked (for whatever reason). In a networking environment, the performance may be unacceptable. http://search.cpan.org/~sgoeldner/DBD-ADO-2.95/lib/DBD/ADO/Const.pm
    and implemented an alternative to Win32::OLE::Const.