A Python wrapper for Perl subroutines
Reason this release was yanked:
buggy
Project description
perl-subroutine-wrapper
A Python wrapper for Perl subroutines.
This module makes it easy to call your Perl subroutines from Python. It is perfect for recycling old Perl code that you are not going to translate to Python.
It makes it possible to comunicate objects between the two languages through JSON object representations.
Valid Python objects passed as parameters are: dict, list, str, int, float, True, False, None.
Valid Perl objects returned are: SCALAR, ARRAY, HASH.
Installation
You can install this module from Pypi:
pip install perlsub
Requirements
In order to use this python module you will need to install jinja2, which will help us with generate the Perl intermediary wrapper dinamically when calling subroutines:
pip install jinja2
You also need Perl installed in your computer. You can check if it is installed and the version with the command:
perl -v
Example of usage
example.py and example.pm show us how to use the module.
In example.pm we have a Perl subroutine such as join that we want to use in our Python script.
sub join {
my ($list1, $list2)=@_;
my @list3;
push @list3, @$list1;
push @list3, @$list2;
print "Joined :)";
return @list3;
}
To wrap this subroutine and use it in Python we have to import the module, create a new Module instance passing the path of the Perl module, and call the call function passing the name of the subroutine, the parameters and the expected Perl object returned like I did in example.py. parameters and returned_type can be None.
from perlsub import Module
example = Module('example.pm')
join = example.call(
subroutine='join',
parameters=[[2, 3], [1, 1]],
return_type='array'
)
print(join)
Output:
PerlCallResult(returned=[2, 3, 1, 1], stdout='Joined :)', error=None)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perlsub-0.0.2.tar.gz.
File metadata
- Download URL: perlsub-0.0.2.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4022a375aa9c868c51253ea2bacc70e3cf0831ded349cd6239b58ee10cc007f1
|
|
| MD5 |
6fa6ed958142998ced3a2e87fd288773
|
|
| BLAKE2b-256 |
c5bb1dd58764351cfd7a9381e24d3ab958d35ebc06d2850dced7c53792afa46d
|
File details
Details for the file perlsub-0.0.2-py3-none-any.whl.
File metadata
- Download URL: perlsub-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e411605f9d68c61e0e6918ea2249ae84bb1c1a6e4be4f9967ddc2e3f353aa4
|
|
| MD5 |
1703f971a5beae5eb76a82e372f1e1fc
|
|
| BLAKE2b-256 |
084a8cec8f39c0e285c4b0d4da61be42d2dd55b80c308c3fe8f6a719387122ad
|