in reply to parallelising processes
Something like this (untested) would do the job:
#! perl -slw use strict; use threads; use threads::shared; my $running :shared = 0; sub thread { { lock $running; ++$running } my $subdir = shift; chdir $subdir; system q[some command ]; { lock $running; --$running } } my @subdirs = ...; for my $subdir ( @subdirs ) { async( \&thread, $subdir ); sleep 1 while $running >= 8; $_->join for threads->list(threads::joinable); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parallelising processes
by RobertCraven (Sexton) on Apr 07, 2011 at 07:52 UTC |