Dear Monks,
I have 2 files, each split into 10 equal parts. I need to run an external C script with each part as an input (keeping parts of two files separate) and parse and combine the results for the entire file. Simplified example;
foreach my $Index ( 0 .. 10 ) {
`Script Input:File_1[$Index], Paramater, Output: 'Results_File_1_'.$In
+dex`;
@Results_1 = Parse the 'Results_File_1_'.$Index using subroutine and a
+ppend to @Results_1;
`Script Input:File_2[$Index], Paramater, Output: 'Results_File_2_'.$In
+dex`;
@Results_2 = Parse the 'Results_File_2_'.$Index using subroutine and a
+ppend to @Results_2;
}
Do something with @Results_1, @Results_2 (both have to finished).
I was wondering if there is an easiest way to fork the processes. I am not familiar with forking and I was thinking about running two processes at once in the background, waiting for them to finish and parse one after another (I am not sure if the appending will not clash if by chance two processes appending to same @Result will try to do it at once). Also I am not sure how to catch errors from the C script (any error should end the script printing the error message). Any suggestions? Many thanks!