问题描述
我的问题是 这一个 一个>.特别是,我有几十个用Perl编写的现有模块,其中一些是面向对象的,而另一些只是导出一组功能.现在,由于我必须用python编写某些脚本,但仍然想调用这些Perl模块,所以我想知道
my question is the inverse of this one. In particular, I've dozens of existing modules written in Perl, some are object oriented and others just export a group of functions. Now since I have to write certain scripts in python but still would like to call those Perl modules, I'm wondering
1)如果可以实现,并且
1) if it is achievable, and
2)如果是这样,什么是最好的方法
2) if so, what would be the best way of doing it
理想情况下,可以这么说,Perl模块对于Python来说就像是黑匣子".像这样:
Ideally, the Perl modules would appear as "black boxes" to Python, so to speak. Something like:
from perl_module import *
return_value = perl_func(arg1, arg2, ...)
和
object = perl_module.new()
object.method1(arg1, arg2, ...)
但是我敢肯定要实现这一目标,如果可能的话,需要在后台导入/运行其他内容.与Inline::Python
对应的任何内容也将很好(但不理想).谢谢!
but I'm sure to achieve this one needs to have something else imported / running at the background, if possible at all. Anything that is the counterpart to the Inline::Python
would also be nice (but not ideal). Thx!
推荐答案
- http://wiki.python.org/moin/PyPerl
- http://www.boriel.com/files/perlfunc.py
这篇关于从Python调用Perl模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!