473,603 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling perl modules from python

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 --
May 11 '06 #1
3 5447
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 ?
May 11 '06 #2
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($wh atever);
$result2 = hash_proc_2($wh atever);

py_calculate( $result1, $result2 );

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

use Inline Python => <<'END_OF_PYTHO N_CODE';

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

def do_something(re sult):
return x - y

END_OF_PYTHON_C ODE
[/--- 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.
May 11 '06 #3
> 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.

May 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2464
by: Chris | last post by:
Hi I am posting this on both the perl and python groups My intention is not to start a war or anything else, I would just like some pragmatic advice. My apologies to the python group I am not very conversant with Python at this stage. that could change soon though.
13
2695
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but not that different. I did like the indent-as-group idea, which was different. Ruby looked very cool. But it was impossible to get good documentation. It seemed like a Japanese cult with a few western initiates. Well, MacOS X ships with Perl,...
52
3742
by: Olivier Scalbert | last post by:
Hello , What is the python way of doing this : perl -pi -e 's/string1/string2/' file ? Thanks Olivier
4
1425
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # some venture into standard modules import os # print all names exported by the module print dir(os)
31
4759
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
9
4508
by: Dieter Vanderelst | last post by:
Dear all, I'm currently comparing Python versus Perl to use in a project that involved a lot of text processing. I'm trying to determine what the most efficient language would be for our purposes. I have to admit that, although I'm very familiar with Python, I'm complete Perl noob (and I hope to stay one) which is reflected in my questions. I know that the web offers a lot of resources on Python/Perl differences. But I couldn't find a...
3
1697
by: Paul Mc Gee | last post by:
hi everyone i have just downloaded the latest version of postgresql and was doing the installation according to the article at http://www.faqs.org/docs/ppbook/x486.htm when i got to the point where the perl and python modules are to be installed. the distribution used in that article is an older version of postgresql and i cant seem to find where the perl and python modules are in the current release. when it didnt work for me i just...
6
10164
by: Dave R | last post by:
Hello group, I had a COM dll in VC 6.0 which my Perl 5.8 modules used to call. With the .Net invent I would like to wrap up my COM functionality into C#. I wanted to know how can my Perl modules call the C# exe? Thanks, Dave P.S : AFAIK, Perl is also interoperable with the .Net languages.
9
5284
by: Carl | last post by:
I am desperately looking for a way to call Python from Matlab. I have become used to Python's rich syntax and large number of libraries, and feel ridiculously clumsy being stuck with Matlab's rather restricted facilities for doing other things than standard mathematical work. Does anyone know of good techniques (or readily available software) for achieving a cross-language support between Python and Matlab? Carl
0
7929
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8065
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8274
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2433
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.