I want to do something akin to the following shell loop in Perl on a computer running Microsoft Windows XP:
while read arg do somecmd $arg -o ${arg}.txt & done <<EOL arg1 arg2 arg3 arg4 arg5 EOL
In other words, I want to iterate a list of arguments and use each one in the invocation of an external program. I want to run the multiple processes simultaneously in the background. I don't really care about stdout or stderr, nor do I care about error checking. (I have another way to check the success or failure of the multiple runs of the command. It's a separate process.)
For me, the trick is emulating in Perl the shell's asynchronous execution à la '&'. I would prefer not to use a module, but I understand I may have to. I'm really looking for the simplest, most straighforward and shell-like solution that gets the job done.
Where is system(1, ...) documented? What does it do? I've seen references to it but I cannot find its documentation.
By the way, I have several Unixish shells installed on the computer and could use one of them for this task. However, the reason I want to use Perl instead of, say, the Korn shell is because the list of arguments isn't actually a trivial one as in the example. Generating and iterating the right arguments in the right order will be much easier to do in Perl than in a shell script.
UPDATE: Thank you for the helpful responses. I was forced to use the Korn shell after all because it's prohibitively difficult to do this kind of thing in Perl compared to the shell. Instead of using asynchronous processes, I just wrote several separate shell loops (i.e., wrapper scripts) and ran them simultaneous. It worked well. I solved the problem by not programming (or at least "programming" much less).
In reply to Simple Perl "Shell" Script on Windows XP to Run Multiple, Simultaneous Processes in Parallel by Jim
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |