136252Swosch#!/usr/local/bin/perl 236252Swosch 336252Swoschif ($#ARGV < 1) { 436252Swosch die "usage master counter command comandargs ... \n"; 536252Swosch} 636252Swosch 736252Swosch$count = $ARGV[0]; shift @ARGV; 836252Swosch@command = @ARGV; 936252Swosch$file = pop(@command); 1036252Swoschundef @ARGV; 1136252Swosch$debug = 0; 1236252Swosch 1336252Swoschfor($i = 0; $i < $count; $i ++) { 1436252Swosch @c = (@command, "$file.$i"); 1536252Swosch warn "Start process: $i @c\n" if $debug; 1636252Swosch open("OUT$i", "| @c") || die "open @c\n"; 1736252Swosch select("OUT$i"); $| = 1; 1836252Swosch} 1936252Swoschselect(STDOUT); 2036252Swosch 2136252Swosch$n = 0; 2236252Swoschwhile(<>) { 2336252Swosch $o = 'OUT' . ($n % $count); 2436252Swosch print $o $_; 2536252Swosch warn "$o $_" if $debug; 2636252Swosch $n++ 2736252Swosch} 2836252Swosch 2936252Swoschfor($i = 0; $i < $count; $i ++) { 3036252Swosch warn "Close process $i\n" if $debug; 3136252Swosch close("OUT$i") || warn "close OUT$i: $!\n"; 3236252Swosch} 3336252Swosch 34