Solved

publicize perl object to visual basic

Posted on 2001-06-19
6
440 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
perl split by | 2 90
transpose into pipe delemited 8 67
Transforming a Soap message to a simple xml message! 10 144
perl: Cleaning meta tags using RegEX 12 64
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now