Solved

publicize perl object to visual basic

Posted on 2001-06-19
6
444 Views
Last Modified: 2010-03-05
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.

Thanks,

Steve


0
Comment
Question by:showell30
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:zmanz
ID: 6215913
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.
0
 
LVL 1

Accepted Solution

by:
zmanz earned 75 total points
ID: 6216016
0
 
LVL 5

Expert Comment

by:Droby10
ID: 6216975
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...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:showell30
ID: 6225780
Sorry for late response, I am trying ActiveState solution today, I will post results soon, I hope.
0
 

Author Comment

by:showell30
ID: 6226376
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.

0
 

Author Comment

by:showell30
ID: 6226377
Thanks, ActiveState solution was perfect.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question