SPUG: Forked Children talking back to the parent?

John Cokos jcokos at ccs.net
Wed Jan 17 09:43:42 CST 2001

Working on a long running perl script, that I think would be better suited to using fork() than running on it's own.

Basically, the pseudocode for it is something like this:

code:------------------------------------------------------------------------------my @to_do_list

push @to_do_list, $something;

foreach my $item ( @to_do_list ) {

    .. do some work.
    if ( I find something else to do)  {
       push @to_do_list, $this_new_thing;


So, you can see that it's an array that can be added to in mid-stream, and continually grows. Depending on the amount of things
"found to do" in the inside loop, it can take hours and hours to run, as that array grows larger.

What I'm wanting to do, is fork off 10 child processes, and have each of them doing the same loop, each aware of the master array's
contents, and each able to push things onto it, so that the other children, when they're in the loop see the new todo items...

Can the children intercommunicate?

If not, can they at least return a value back to the parent?
In this case, we could have it fork 10, give them a task, get back the new todo items found, and die. Then, fork 10 new kids, etc

Thanks, John
  John Cokos, President / CEO: iWeb Inc.
  jcokos at ccs.net

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/

More information about the spug-list mailing list