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); }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: parallelising processes
by RobertCraven (Sexton) on Apr 07, 2011 at 07:52 UTC
    Very sorry for the late thanks. Another project got priority, but got back on the old one and your idea works great, exactly what I was looking for.

    Thanks!