Solved

Embedding Python in Perl?

Posted on 1998-06-30
2
725 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
2 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
Comment Utility
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
Comment Utility
Fourth way: write an XSUB interface. (see `perldoc perlxstut`)
0

Featured Post

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

Join & Write a Comment

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…
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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

10 Experts available now in Live!

Get 1:1 Help Now