Porting Perl to Python

Another approach is that you might be able to reuse existing Perl code and complement it with new Python code.

One possibility that might work for you is to use the perl Python module, which allows you to execute Perl code inside Python.

Another approach is to have Perl produce its output as simple text/JSON/YAML files which is parsed by Python for further processing. Thus, I was able to use my legacy Perl code without rewriting it, while switching to Python. Your mileage may vary, as this "gluing" method might be too slow for your needs. This "pass files" method is good when you have long calculations that produce intermediate results: you can start the computation in Perl, and continue it in Python.


There are so many ways of doing the same thing in Perl that writing any sort of crosscompiler would be... painful at best. Reconstruct (don't just translate) the program manually.


Keep a phrasebook handy as you go through the code you want to port.

Tags:

Python

Perl