my @data = genData(); my $pid = open OUT, '-|', 'python theScript.py' or die; print OUT $_ for @data; close OUT; waitpid $pid, 0; ## The python script has finished.