[Chicago-talk] Script design question

Steven Lembark lembark at wrkhors.com
Mon Dec 19 10:23:01 PST 2005

-- "Young, Darren" <Darren.Young at ChicagoGSB.edu>

> Looking for some input on a script before I sit down and try to create
> it. The basic need is to launch 4 system commands (at the same time) and
> watch each one for completion and when one is done to start another.
> Basically, it needs to keep 4 child processes running up to a defined
> end.

Look at Schedule::Parallel. You pass in a paralle job
count and array of closures. It tracks the stauts and 
returns the unused portion if any of the jobs returns
non-zero (so you can fix the problem or report what 
went wrong). 


The closures allow you to pass in arbitray code that 
has to be run.

For the backup you can use a single sub that takes
what has to be backed up as an argument and then
submit it with something like:

    use Schedule::Parallel;

    my @backupz = 

    my @queue = 
        my $path = $_;

        sub { imbackup $path }

    runqueue 4, @queue;


S::P will keep track of exit status and report on non-zero
exits or signals killing things.

Steven Lembark                                       85-09 90th Street
Workhorse Computing                                Woodhaven, NY 11421
lembark at wrkhors.com                                     1 888 359 3508

More information about the Chicago-talk mailing list