auto.pl!!...execute this file alone!
system "ls -1 /home/input/ > /home/list";
my @test = ();
@array=qw{1.pl 2.pl};
foreach $i(@array)
{
my $pid = fork();
if($pid==0)
{
#child
system "perl ".$i
;
exit(0);
}
elsif($pid)
{
#parent
push(@test,$pid);
}
}
foreach (@test)
{
waitpid($_,0);
}
1.pl!!!!!!!!
my @array=();
my %hash=();
open (LIST, "</home/list");
@array= <LIST>;
close LIST;
foreach (@array){
chop($_);
}
$len=@array;
$rc=0;
$i=0;
$y=0;
begin: while($i<$len)
{
while($rc<3)
{
my $rcpid= fork();
if($rcpid==0)
{
system "/home/x.pl $array
$i";
print "child".$i."\n";
exit(0);
}
elsif($rcpid)
{
print "Parent ".$rcpid."\n";
push(@kick,$rcpid);
$rc++;
$a = $array
$i;
$hash{ $i } = $a;
$i=$i+2;
}
}
$x=$i-6;
if($rc==3)
{
while($x < $i)
{
$temp=$array
$x.".out";
if (-e "/home/$temp")
{
delete $hash{$x};
$rc--;
print "inside begin\n";
goto begin;
break;
}
else
{
$x=$x+2;
}
}
}
foreach (@kick)
{
waitpid($_,0);
}
sorry couldnt figure out how to give the spaces at the beginning of the line...and not a lot of time too...my apologies to fellow monks...this can be extended to any numbers...i have given example of 1.pl...you can do this till n i guess and also you can change the number of forks per file....hope this aint bad perl hacking...:-s ...cheers