Solved

Embedding Python in Perl?

Posted on 1998-06-30
2
738 Views
Last Modified: 2010-05-18
I have a friend who is damn good programmer, but (unfortunately) his scripting language of choice is Python, while I am Perl lover. Does anybody know of a good, easy way to embed Python code (or use a "use" or "require") into a Perl script on a Unix machine? Thanks....
0
Comment
Question by:Dyrewolf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
ID: 1208251
I can come up with only three (not very good) ways to do this.

The first is that you could obviously use system calls to execute python programs.  You could even have some communication between the child python program and the parent perl program using simple ipc.  However, you're not going to get the same results as simply calling a subroutine.

Second way:  Building on the last, you set up a perl server and a python server (whether the python server starts the perl , or the perl starts the python, or they're both started independently doesn't matter). The two of them communicate with each other via straight sockets, and you avoid start up time by having them both running

Third way: Write a python interpreter in perl :)

For 50 points, what do you expect? :)
0
 
LVL 84

Expert Comment

by:ozo
ID: 1208252
Fourth way: write an XSUB interface. (see `perldoc perlxstut`)
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…

738 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