从Python调用Perl模块 [英] Calling a Perl module from Python

查看:164
本文介绍了从Python调用Perl模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是 这一个 .特别是,我有几十个用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!

推荐答案

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

这篇关于从Python调用Perl模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆