Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > calling perl modules from python

Reply
Thread Tools

calling perl modules from python

 
 
David Bear
Guest
Posts: n/a
 
      05-11-2006
I have a hash function written by another organization that I need to use.
It is implemented in perl. I've been attempting to decode what they are
doing in their hash function and it is taking way too long. I've
identified two functions in a perl module that I would like to 'call' from
a python program. I found the following:
http://www.annocpan.org/~GAAS/pyperl-1.0/perlmodule.pod

and wondered if anyone had any comments. This thing implements a perl
interpreter inside python. That seems like overkill to me.

I wonder what wisdom this group can offer.

--
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
 
Reply With Quote
 
 
 
 
Mirco Wahab
Guest
Posts: n/a
 
      05-11-2006
Hi David

> I have a hash function written by another organization that I need to use.
> It is implemented in perl. I've been attempting to decode what they are
> doing in their hash function and it is taking way too long. I've
> identified two functions in a perl module that I would like to 'call' from
> a python program. I found the following:
> http://www.annocpan.org/~GAAS/pyperl-1.0/perlmodule.pod
>
> and wondered if anyone had any comments. This thing implements a perl
> interpreter inside python. That seems like overkill to me.
>
> I wonder what wisdom this group can offer.


Why not the other way around.
Use their .pl-program and
use the functions inside it -
then cross-call in to your
python module:

[--- someperl.pl ---]
py_prepare

$result1 = hash_proc_1($whatever);
$result2 = hash_proc_2($whatever);

py_calculate( $result1, $result2 );

# - - - - - - - - - - - - - - - - - - #

use Inline Python => <<'END_OF_PYTHON_CODE';

def py_calculate (r1, r2):
do_something(r1 * r2)

def do_something(result):
return x - y

END_OF_PYTHON_CODE
[/--- someperl.pl ---]

This approach ensures that the
strange perl functions run clean
int their native environment.

You have access to all your py-
Modules, as in a normal python-
environment (Python globals are
directly imported, afaik).

[--- someperl.pl ---]
use Inline Python;

doit();

__END__
__Python__

from mylibrary import doit
...
...
[/--- someperl.pl ---]

(http://search.cpan.org/~neilw/Inline....22/Python.pod)

I use this sometimes, it is quite nice.

Regards

M.
 
Reply With Quote
 
 
 
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      05-12-2006
David Bear a écrit :
> I have a hash function written by another organization that I need to use.
> It is implemented in perl. I've been attempting to decode what they are
> doing in their hash function and it is taking way too long.


No comment...

> I've
> identified two functions in a perl module that I would like to 'call' from
> a python program. I found the following:
> http://www.annocpan.org/~GAAS/pyperl-1.0/perlmodule.pod
>
> and wondered if anyone had any comments. This thing implements a perl
> interpreter inside python. That seems like overkill to me.


<AOL />

> I wonder what wisdom this group can offer.


What about writeing a small perl script that let you call the needed
functions from the commandline, then calling this script from Python ?
 
Reply With Quote
 
Ravi Teja
Guest
Posts: n/a
 
      05-12-2006
> This thing implements a perl interpreter inside python. That seems like overkill to me.

It does not *implement* Python, just embeds it. It is not an overkill
if you can get it to work quickly and move on.

If you are Windows, you can use COM. Support is available for both
languages and is fairly simple to use.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash calling Php calling Perl Bill H Perl Misc 3 06-04-2009 03:32 PM
Problem calling python modules from python apache handler mannewalis Python 1 10-16-2007 11:39 PM
Calling Perl Modules from ruby barjunk Ruby 4 06-09-2007 02:39 AM
Perl Multithreading and use of Perl Modules Nate Perl Misc 8 07-07-2005 05:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57