skip to navigation
skip to content

perlprocess 0.1

This module provides a way to execute perl statements in a parallel perl process.

A priori, it is a strange idea to execute pieces of perl code from a python program, unless you have to use an existing perl API and you want to write as less perl code as possible. In this case (and only it, in my opinion), perlprocess may help you. See VMPython as an example of use.

When a perlprocess object is created, a separate process is launched, running a small perl script that expects commands on STDIN. If a string is given as parameter to the perlprocess constructor, it is used as a prolog for the perl script. It is usefull mainly to declare use clauses or some useful functions.

When invoking the run(command) method of the perlprocess object, the command is sent to the perl process as a string containing eventually several perl statements, eventually among several lines. This string is evaluated, the result is printed on stdout. If an error occurs (perl variable $@ not empty), PerlRuntimeError is raised. If you define a perl variable of any kind in the perl process, this variable remains alive until you undefine it.