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

I am using ActiveState Perl on Windows 2000 and have need to instantiate and access a COM object. I have noticed that ActiveState does provide a module for this in their toolkit (a bit pricy, however), but have not found any modules for this in the opensource arena. I appreciate any input on how I might do this.

Replies are listed 'Best First'.
Re: Accessing COM Objects from Perl
by dws (Chancellor) on Jan 24, 2002 at 02:20 UTC
    I am using ActiveState Perl on Windows 2000 and have need to instantiate and access a COM object.

    Use Super Search and look for message that contain the string "Win32::OLE". You'll find lots of examples of how to instantiate and access COM objects, including examples that cover Excel and others.

    Use this as an excuse to figure out how to search this site effectively. Such an exercise pays high dividends.

Re: Accessing COM Objects from Perl
by JayBonci (Curate) on Jan 24, 2002 at 02:31 UTC
    If you are instantiating a COM object for IIS (using ActiveState PerlScript), you can simply use the $Server object to do so. Remember, ADO is really just a complex series of COM objects, so you would do is instead of:
    my $rs = $Server->CreateObject("ADODB.Recordset");


    You can do:


    my $ea = $Server->CreateObject("Excel.Application"); #or any other sort of COM object reference #look in your registry to see what you have
    If you are just looking for an object in a normal shebang script, then try CPAN / ActiveState documentation.
Re: Accessing COM Objects from Perl
by moodster (Hermit) on Jan 24, 2002 at 01:20 UTC
    It sounds like Win32::OLE is what you need; you can find it on CPAN. You *did* have a look on CPAN before asking around here, right?

    Cheers,
    -- moodster

Re: Accessing COM Objects from Perl
by smartin90220 (Initiate) on Jan 24, 2002 at 01:29 UTC

    I think that perhaps the question is pointing in the direction of the creation of a Perl based COM object. That is something that ActiveState offers. Is this correct AnonMonk?

Re: Accessing COM Objects from Perl
by Anonymous Monk on Jan 24, 2002 at 05:06 UTC
    Thank you all for your comments. I was able to get my stuff done with your help. I did do a lot of searching on COM information (including on CPAN, of course) before logging my question. What I forgot is that COM has morphed itself into many different technologies. I would have done better to search on OLE. Thanks again!