always_coys has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks I am trying to run a Perl script from Python in Windows. It is my first attempt and I am getting nowhere. My code for running a Hello World program in Perl, from Python is given below.
import subprocess, sys perl = "C:\\Perl64\\bin\\perl.exe" perl_script "C:\\vub_work\\py_learn\\hello.pl" pl_script = subprocess.Popen([perl, perl_script], stdout=sys.stdout) pl_script.communicate()
I end up getting up the following error:
File "<ipython-input-5-d6c6696cc648>", line 4 perl_script "C:\\vub_work\\py_learn\\hello.pl" ^ SyntaxError: invalid syntax
It would be great if you could help.

Node original content restored and reformatted by erzuuli

Replies are listed 'Best First'.
Re: (OT) Help with running a Perl script from Python
by Corion (Patriarch) on Dec 06, 2020 at 09:37 UTC

    This is purely a Python question.

    Have you looked at the problematic line? Have you compared it with the previous line? What is the problematic line supposed to do? What is the previous line supposed to do?

      Hi, the problematic line simply refers to the location where my Hello World program in Perl is located. Thanks.

        The originally posted code:

        perl = "C:\\Perl64\\bin\\perl.exe" perl_script "C:\\vub_work\\py_learn\\hello.pl"

        In the
            perl = "C:\\Perl64\\bin\\perl.exe"
        statement, why is the quoted string assigned to the perl variable, and in
            perl_script "C:\\vub_work\\py_learn\\hello.pl"
        why is the quoted string not assigned to the perl_script variable?


        Give a man a fish:  <%-{-{-{-<

Re: (OT) Help with running a Perl script from Python
by LanX (Saint) on Dec 06, 2020 at 09:54 UTC
    you are wrong here and should ask in a Python board.

    This question is so lazy (the error message is different from the shown source) that nobody here should even consider feeding it.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Thanks. Will remove the question.
Re: (OT) Help with running a Perl script from Python
by perlfan (Parson) on Dec 07, 2020 at 20:08 UTC
    This is not a "running perl from python" specific question either, you can treat it as running any external program from Python. They do that a lot, I hear. xD