publicize perl object to visual basic

Hello.  I have written a Perl program that calls HTML::TreeBuilder to parse an HTML document.  I want to connect this to a little VB program that has a tree-view control and a browser control.  (I basically want to use this program to analyze and drill down on web pages.)

So, I need a mechanism to make a Perl object public to VB.  Here is what I've rigged up so far:

1. VB program calls Perl program.
2. Perl program creates TreeBuilder object (actually a light wrapper around TreeBuilder).
3. Perl program uses HTTP::Deamon to be a little web server, and it hooks up all requests to the TreeBuilder object.
4. VB program calls into Perl to get parsed out portions of the HTML file to fill up TreeView object.  The VB program gets data from the Perl program my making HTTP GET requests with Microsoft's OpenURL call.

This scheme works, and it has a nice side advantage of allowing you to test the Perl code with a browser, but I'd really prefer a more lightweight scheme.  Can some one propose a more direct IPC mechanism?  The Perl and VB programs will always be on the same Windows box.



Who is Participating?
You may want to make a PERL COM object. By doing that
you can expose your PERL code to any language that
supports COM. The Fall '98 issue of The Perl Journal
has an article on how to do it. I'm sure you can find
a more recent how-to somewhere.
the other option would be to use the Win32 createobject within your perl source to create a vb com/activex component and call methods on that...
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

showell30Author Commented:
Sorry for late response, I am trying ActiveState solution today, I will post results soon, I hope.
showell30Author Commented:
Okay, the ActiveState solution was pretty painless.  I installed the trial version of PerlCom to make this work.

Here is the VB code I ended up using:
    Dim objPerlCOM
    Set objPerlCOM = CreateObject("PerlCOM.Script")
    Dim objSteve
    Dim path As String
    path = app.path
    objPerlCOM.EvalScript ("push @INC, '" & path & "';")
    Dim file As String
    file = "c:\mydocuments\cdx\analyze\perl\vanilla.htm"
    Set objSteve = objPerlCOM.CreateObject("Analyze", "new", file)
    MsgBox objSteve.gethtml("1,1,3")
The ActiveState documentation was helpful.  The trickiest thing I had to do was get @INC to include the current directory; for some reason, VB's current directory was not searched even though my @INC include the "." directory.

showell30Author Commented:
Thanks, ActiveState solution was perfect.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.