Python Programming/Extending with Perl

From Wikibooks, open books for an open world
Jump to navigation Jump to search


It is possible to call Perl functions and modules in Python. One way to do that is the PyPerl Module. It is not developed actively any more and for it to work in newer versions, one has to use this version and apply the patches.

import perl
perl.eval( "use lib './' ")
perl.require( 'Module::ModuleName' )

obj = perl.callm("new", 'Module::ModuleName'  )
obj[ '_attr1' ] = 9
obj[ '_attr2' ] = 42
obj.fxn1()

It is thus possible to handle Perl objects, change their attributes and call their methods.

See also[edit | edit source]