Solved

Embedding Python in Perl?

Posted on 1998-06-30
2
743 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

636 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