Mailing List Archive

Using perl in python
I have a bunch of perl libraries that I would like to call in my python
scripts. Is this possible?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Using perl in python [ In reply to ]
Brenda <bbailey08@my-deja.com> wrote:
: I have a bunch of perl libraries that I would like to call in my python
: scripts. Is this possible?

It is possible; Tkinter utilizes an embedded Tk interpreter. You
would have to write a Perl interpreter. There may be some people
around who might help you with that. I'm in the middle of embedding
another interpreter myself.

I've found that it is more efficient (and more fun) to convert the
libraries to Python. The code is invariably clearer.

-Arcege
Using perl in python [ In reply to ]
Michael P. Reilly writes:

> I've found that it is more efficient (and more fun) to convert the
> libraries to Python. The code is invariably clearer.

You have got some spare time to do the whole of CPAN? Much appreciated.
Using perl in python [ In reply to ]
In article <6cs73.2432$nn.739920@news.shore.net>,
Michael P. Reilly <arcege@shore.net> wrote:
>Brenda <bbailey08@my-deja.com> wrote:
>: I have a bunch of perl libraries that I would like to call in my python
>: scripts. Is this possible?
>
>It is possible; Tkinter utilizes an embedded Tk interpreter. You
>would have to write a Perl interpreter. There may be some people
>around who might help you with that. I'm in the middle of embedding
>another interpreter myself.
>
>I've found that it is more efficient (and more fun) to convert the
>libraries to Python. The code is invariably clearer.
.
.
.
There's an even grosser approach that I've semi-automated.
I build Perl scripts as strings from within Python, and
send them out to an external (Perl) process for execution.

The automation part is that I have conventions for expressing
variable references so I can get data to flow conveniently
back and forth. It's only "semi-", 'cause I tinker with
exception-handling and such most times I use it.

When do I use it? Typically, when CPAN has something I
want in Python. I do a cognate translation of the CPAN
interface into Python, and steal the implementation from our
Perl colleagues. When it becomes important enough, or I
make time for fun, I rewrite the implementation in Python.
--

Cameron Laird http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com +1 281 996 8546 FAX
Using perl in python [ In reply to ]
hi,
try and use swig (www.swig.org) - that is an interface generator that i
had come across some time back. Since i don't remember things clearly, it
might not be able to glue python and perl together (i used it to glue C and
python code).

Good luck
ashish

"Michael P. Reilly" wrote:

> Brenda <bbailey08@my-deja.com> wrote:
> : I have a bunch of perl libraries that I would like to call in my python
> : scripts. Is this possible?
>
> It is possible; Tkinter utilizes an embedded Tk interpreter. You
> would have to write a Perl interpreter. There may be some people
> around who might help you with that. I'm in the middle of embedding
> another interpreter myself.
>
> I've found that it is more efficient (and more fun) to convert the
> libraries to Python. The code is invariably clearer.
>
> -Arcege
Using perl in python [ In reply to ]
Ashish Goyal <ashishg@pobox.com> wrote:
: hi,
: try and use swig (www.swig.org) - that is an interface generator that i
: had come across some time back. Since i don't remember things clearly, it
: might not be able to glue python and perl together (i used it to glue C and
: python code).

Correct, swig probably can't. The Perl C API is too complex to do this
with SWIG (of course); the interface file would probably be larger than
the C code if you didn't use SWIG. It's doable in C. Also, unless
specially compiled, Perl will only allow one interpreter per process
(cf. -DMULTIPLICITY). A new release of SWIG came out a week or two ago
that might make things easier, but I doubt the interface file would be
shorter.

I'm never surprised at how overly complicated Perl makes things.

-Arcege