calling perl modules from python

Discussion in 'Python' started by David Bear, May 11, 2006.

  1. David Bear

    David Bear Guest

    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 --
    David Bear, May 11, 2006
    #1
    1. Advertising

  2. David Bear

    Mirco Wahab Guest

    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-Python-0.22/Python.pod)

    I use this sometimes, it is quite nice.

    Regards

    M.
    Mirco Wahab, May 11, 2006
    #2
    1. Advertising

  3. 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 ?
    Bruno Desthuilliers, May 12, 2006
    #3
  4. David Bear

    Ravi Teja Guest

    > 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.
    Ravi Teja, May 12, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mannewalis
    Replies:
    1
    Views:
    885
    Graham Dumpleton
    Oct 17, 2007
  2. barjunk

    Calling Perl Modules from ruby

    barjunk, Jun 4, 2007, in forum: Ruby
    Replies:
    4
    Views:
    111
    Sean T Allen
    Jun 9, 2007
  3. Nate
    Replies:
    8
    Views:
    271
  4. garey
    Replies:
    3
    Views:
    153
    Joe Smith
    May 29, 2007
  5. Bill H

    Flash calling Php calling Perl

    Bill H, Jun 4, 2009, in forum: Perl Misc
    Replies:
    3
    Views:
    240
    Mark Smith
    Jun 4, 2009
Loading...

Share This Page