Wrapper Script Help With Perl Scripts

I have tried looking through wrapper scripts throughout the forum, but I don't think they were able to answer my question (either that or I'm just confused).
Basically, I have a Perl script that I want to run in parallel 4 times with parameters, wait for all of them to finish, then run another script.

Ex. perl test.pl input1.txt output1.txt &&
perl test.pl input2.txt output2.txt && ....etc.

How would I do this? Any help is greatly appreciated!

#!/bin/sh

for N in 1 2 3 4
do
        perl test.pl input${N}.txt output${N}.txt &
done

wait

Sorry, I should've been more specific.

I would also like to run this script in a Windows environment.
Preferably, I would like to avoid using UNIX environments (ex. Cygwin) since I'll be running this in a Windows environment.
As far as I'm aware, .sh scripts don't work in Windows (unless I missed something...).

My Perl scripts all run fine; just need to get the wrapping script all set up and I'll be good to go.

use Perl threads or I think Windows powershell can handle this.

Hmm, crud, Perl threads... I haven't done threading for a long time...
Well, if it works, then that's what I will have to refresh my memory with.
Many thanks!! :slight_smile:

Before you dive into the world of threads, how about a wrapper script written in Perl that forks and execs your programs?

Does fork() work on Windows?

On those systems that I've tried on: yes. Although it's a good deal slower than on UNIX, but that's usually only a problem if the fork'd part finished very fast.

Windows doesn't have a genuine fork(). (I'm still not sure Windows has genuine copy-on-write, for that matter.) But it's possible to write something that acts like it, which I guess they've done.