sub doWork
{
my $files=shift;
for my $file (@$files)
{
#deal with file.
}
}
sub getFiles
{
#read files from dir and
#you can dispatch the files into a number of arrays
#these you should pass into subprocesses.
}
sub main
{
my @arrayofarray=getFiles($n);#$n can be the number of subprocs.
foreach my $files (@arrayofarray)#$files is a reference to array.
{
my $pid=fork();
if($pid==0)
{
return doWork($files);
}
}
wait(-1);#wait for all subprocesses.
}
阅读(943) | 评论(0) | 转发(0) |