Solved

publicize perl object to visual basic

Posted on 2001-06-19
6
437 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
Comment Utility
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
Comment Utility
0
 
LVL 5

Expert Comment

by:Droby10
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

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

Author Comment

by:showell30
Comment Utility
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
Comment Utility
Thanks, ActiveState solution was perfect.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

13 Experts available now in Live!

Get 1:1 Help Now