1

Let's say I have an example perl program, that I can run from CMD (Windows 7) using the command:

perl hello.pl

This outputs:

Hello World!

I can place this in a file using:

perl hello.pl > output.txt

However, what I would like to do, is give it to another application, for this I need it to be fed to a Python application. I give arguments to my Python application using the syntax:

python python.py Arg1 Arg2 Arg3

Assuming my Perl program only gives one parameter, is there a way to run a Python application once it has finished with this parameter?

Alexander Craggs
  • 6,776
  • 4
  • 20
  • 38

1 Answers1

5

Make your python program read the output from the perl program from sys.stdin and pipe the perl program's stdout to it:

perl hello.pl | python python.py Arg1 Arg2 Arg3

I tested this going from one python program to another and in the second python program just did:

import sys

inp = sys.stdin.readline()
print(inp)
martineau
  • 112,593
  • 23
  • 157
  • 280