in reply to Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';
Looking at your profile output it shows that Win32::OLE::Const::_Typelib is being called 538 times. Presumably, once each for 538 imported constants. The pod shows an alternative syntax that gives you back a hash of the constants rather than exporting each as a constant sub. It's possible, though I cannot test it here, that using the alternate syntax mught take less time?
From Win32::OLE::Const pod:
The first example imports all Excel constants names into the main name +space and prints the value of xlMarkerStyleDot (-4118). use Win32::OLE::Const ('Microsoft Excel 8.0 Object Library'); print "xlMarkerStyleDot = %d\n", xlMarkerStyleDot; The second example returns all Word constants in a hash ref. use Win32::OLE::Const; my $wd = Win32::OLE::Const->Load("Microsoft Word 8.0 Object Librar +y"); foreach my $key (keys %$wd) { printf "$key = %s\n", $wd->{$key}; } printf "wdGreen = %s\n", $wd->{wdGreen}; The last example uses an OLE object to specify the type library: use Win32::OLE; use Win32::OLE::Const; my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); my $xl = Win32::OLE::Const->Load($Excel);
It might even be, but again I cannot test this guess, that using the third form above would only import a subset of available constants applicable to excel?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Over a minute to do: use Win32::OLE::Const 'Microsoft Excel';
by spikey_wan (Scribe) on Sep 13, 2004 at 12:49 UTC | |
by BrowserUk (Patriarch) on Sep 13, 2004 at 19:51 UTC |