Solved

Embedding Python in Perl?

Posted on 1998-06-30
2
735 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Remove Malware code from PHP file 6 98
pattern matching in perl 2 111
.properties file to call function/method 9 63
perl getopt long help 34 85
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

756 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