calling perl modules from python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Bear

    #1

    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:


    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 --
  • Bruno Desthuilliers

    #2
    Re: calling perl modules from python

    David Bear a écrit :[color=blue]
    > 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.[/color]

    No comment...
    [color=blue]
    > 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.[/color]

    <AOL />
    [color=blue]
    > I wonder what wisdom this group can offer.[/color]

    What about writeing a small perl script that let you call the needed
    functions from the commandline, then calling this script from Python ?

    Comment

    • Mirco Wahab

      #3
      Re: calling perl modules from python

      Hi David
      [color=blue]
      > 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.[/color]

      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.

      Comment

      • Ravi Teja

        #4
        Re: calling perl modules from python

        > 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.

        Comment

        Working...