从Python调用Perl模块

时间:2022-01-17 23:12:24

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

我的问题与此相反。特别是,我有几十个用Perl编写的现有模块,一些是面向对象的,另一些只是导出一组函数。既然我必须在python中编写某些脚本但仍想调用那些Perl模块,我很想知道

1) if it is achievable, and

1)如果可以实现,并且

2) if so, what would be the best way of doing it

2)如果是这样,最好的方法是什么

Ideally, the Perl modules would appear as "black boxes" to Python, so to speak. Something like:

理想情况下,Perl模块对Python来说可能是“黑盒子”,可以这么说。就像是:

 from perl_module import *
 return_value = perl_func(arg1, arg2, ...)

and

 object = perl_module.new()
 object.method1(arg1, arg2, ...)

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!

但我肯定会实现这个,如果可能的话,需要在后台导入/运行其他东西。任何与Inline :: Python相对应的东西也会很好(但并不理想)。谢谢!

1 个解决方案

#1


6  

  1. http://wiki.python.org/moin/PyPerl
  2. http://wiki.python.org/moin/PyPerl
  3. http://www.boriel.com/files/perlfunc.py
  4. http://www.boriel.com/files/perlfunc.py

#1


6  

  1. http://wiki.python.org/moin/PyPerl
  2. http://wiki.python.org/moin/PyPerl
  3. http://www.boriel.com/files/perlfunc.py
  4. http://www.boriel.com/files/perlfunc.py