$#tmp count is 100.
foreach my $i (0..$#tmp) {
# Forks and returns the pid for the child:
my $pid = $pm->start($i);
if ($pid) {
print "Pid of Child process $pid\n";
next;
};
}
Prints out the child process 100 times.
The below code reads the files in directory and splits files and directory name.
my $filename = $tmp[$i]->filename();
my $file = IO::File->new("<$filename") or die "Can't open $filen
+ame\n";
while((my $line) = $file->getline()) {
last unless defined($line);
chomp $line;
my ($dir, $file) = split(/\t/, $line);
The below code calls the subroutine which opens the log file in append mode and write to file. here all the process write to the file and it is not synchronized. The problem is to write to log file one process after the another.
$process->($dir, $file, $config, $log);
}
$pm->finish; # Terminates the child process
How can I do this