While this dosn't actually answer your question about juggling forks, I will say that this is the perfect place to use threads. Whenever you want to return data from a process, a thread makes life easier. You didn't say or show how you were going to return values....I assume through external files? Anyways, here is a simple example using threads. It is simplified purposely for the example, in a real script, you probably would put everything into a hash.
#!/usr/bin/perl use warnings; use strict; use threads; my $thr1 = threads->new(\&sub1); my $thr2 = threads->new(\&sub2); my $thr3 = threads->new(\&sub3); my $ReturnData1 = $thr1->join; print "Thread1 returned @$ReturnData1\n"; my $ReturnData2 = $thr2->join; print "Thread2 returned @$ReturnData2\n"; my $ReturnData3 = $thr3->join; print "Thread3 returned @$ReturnData3\n"; print "Press any key to exit\n"; <>; ############################################## sub sub1 { my @values = ('Fifty-six','foo', 1); sleep 1; return \@values; } ############################################## sub sub2 { my @values = ('Forty-two','bar', 2); sleep 2; return \@values; } ########################################## sub sub3 { my @values = ('Sixty-six','baz', 3); sleep 3; return \@values; } # join() does three things: it waits for a thread to exit, # cleans up after it, and returns any data the thread may # have produced.

I'm not really a human, but I play one on earth. flash japh

In reply to Re: forks, how do that? by zentara
in thread forks, how do that? by apolo

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.