A
A
Asya2019-02-14 17:56:28
Perl
Asya, 2019-02-14 17:56:28

How to add perl script to python project?

I have a project written in python, and there are a couple of perl scripts that have to be run separately.
1) Are there any converters from pearl to python?
2) How to attach a pearl script to a project using Python modules/libraries?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zanak, 2019-02-15
@asyaevloeva

There are no converters from perl to python, because these languages ​​are quite different. In simple cases, interlinear translation is possible, but it still has to be done by a person.
The most correct way is not to fasten the camel to the snake, but to transfer everything into one language. At a minimum, this will save you the trouble of having 2 languages ​​on the system with all the dependencies that this vinaigrette requires. Perl is far from being as complicated as it is customary to think about it, and there are a lot of books on this language on the net, including in Russian. If you are familiar with php, then it will be enough to "get comfortable with the differences" to understand what is happening, it will take you 4 - 5 hours. And then everything depends on the speed of your coding in python.
If you still go on a difficult path, then you need details about the perl part:
- if the task is to start, wait for the end and continue working, os.system will help you
- if this is a service that you need to start and then communicate with it from python, then it should start as an independent process, and here you need to look towards subprocess, for example. the same module will allow you to clean up after yourself, and complete the perl part at the end of the work
- if you need to run a script and communicate with it through its stdin / stdout, then look at subprocess.Popen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question