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); }
In reply to Re: parallelising processes
by BrowserUk
in thread parallelising processes
by RobertCraven
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |