I am trying to create a small Perl program with several processing capabilities. Since there are slight changes in my requirements, I cannot find any such scripts anywhere.
I need to read a large log file from STDIN and give first the first number N (large number) of lines for the first child process, and then the next N number of lines to the second child process, etc. I also have a specific constant which is the maximum number of child processes allowed to run at the same time. As soon as the maximum number of children reaches, the parent will wait until the child finishes his work and provides him with another N lines.
The parent process also collects multi-line (5-10 lines) output returned by each child process when they end, and stores it in an array. Then the parent continues to process the contents of this array and finally display the results.
Is there a better sample script that I can modify and use, or can someone help me by sharing one here? I prefer to use only pipes for interaction between processes and to simplify things as much as possible.
Edit: Can someone show an example of how this can only be done using pipes from the IO :: Handle module?
source share