#!/usr/bin/perl #... $maxfork= 20; # maximum number of procs $stime = time(); # get current time in secs since 1970 # --- check if older proc is already running ------ stat $lock; if (-e _) { $curtime = scalar localtime($stime); print STDERR "$curtime: LOCKED, skipping.\n"; exit 1; } # nope, so lock it open LOCK, ">$lock"; print LOCK "$$"; close LOCK; $loop = 0; $forked = 0; for ($count=1; $count<50; $count++){ if ( $forked > $maxfork) { wait; $forked--; } if ( $pid = fork ) { $forked++; # parent } elsif ( defined $pid) { # child # The place where I would like to do the work against one of the array cells? print "Fork number is $forked - Counter is $count\n"; } else { die "error forking!"; } $loop++; } # wait for child procs while ( wait != -1) { ; };