| Next | Trivial Utilities | 161 | 
Here's the main logic of the program and it is :
        my %pid;
        while (@ARGV) {
          if (keys(%pid) < $opt{n}) {
            $pid{spawn(@cmd, shift @ARGV)} = 1;
          } else {
            delete $pid{wait()};
          }
        }
        1 while wait() >= 0;
I glow with pride every time I see delete $pid{wait()}
spawn merely forks a subprocess to run the command, returns the pid
| Next | Menu | ![]()  | 
    Copyright © 2012 M. J. Dominus |