in reply to running multiple system commands in parallel
If you like simple, then where you would code:
#! perl -slw use strict; #... my $output1 = `somecommand`; my $output2 = `someothercommand`; #... print for $output1, $output2;
Do:
#! perl -slw use strict; use threads; #... my $t1 = async{ `perl -e"print, sleep 1 for 1 ..10"` }; my $t2 = async{ `perl -le"print, sleep 1 for 'a'..'z'"` }; #... my $output1 = $t1->join; my $output2 = $t2->join; print for $output1, $output2;
(Note:The second snippet is an actual working example!)
And er...that's it really. It requires a little more if you have lots of commands to run and reason to limit the level of concurrency. But not much.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: running multiple system commands in parallel
by incognito129 (Acolyte) on Aug 29, 2009 at 12:43 UTC |