So, it looks like you're confident in the merging algorithm, so the real question is spawning the second process to merge the old indexes. Again, the pointers above from other monks are necessary reading if you're going to use fork() and exec(), but in general the following idiom is common:
use POSIX ":sys_wait_h"; my %kids = (); # Signal Handler for SIGCHLD sub sigchld_handler{ while (($pid = waitpid(-1, &WNOHANG)) > 0) { delete $kids{$pid}; } $SIG{CHLD} = \&sigchld_handler; } $SIG{CHLD} = \&sigchld_handler; # You can repeat this for as many secondary # processes as you need to merge the old indexes for (1..3) { if (my $pid = fork) { # Parent Process keep track of forked children $kids{$pid} = 1; } else { # Child process # ... do merging of old indexes here sleep(3); exit 0; # MUST EXIT HERE } } while (keys %kids > 0) { sleep(1); # wait for all children to finish } exit 0;
The SIGCHLD handler is there to let you know which of your child processing doing the merging completed successfully (or not), giving you a way to handle them properly. See the previously pointed to documentation about getting the actual exit value, signal and so forth from the completed child process. But, this framework should be enough to get you going if you have the merging algorithm down pat.

In reply to Re^3: meddling with forces I can't understand by tuxz0r
in thread meddling with forces I can't understand by downer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.