?
Solved

publicize perl object to visual basic

Posted on 2001-06-19
6
Medium Priority
?
465 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 300 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Six Sigma Control Plans
Suggested Courses

839 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