in reply to Re^3: process synchronize.... Please help me out
in thread process synchronize.... Please help me out
Prints out the child process 100 times. The below code reads the files in directory and splits files and directory name.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; }; }
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.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);
How can I do this$process->($dir, $file, $config, $log); } $pm->finish; # Terminates the child process
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: process synchronize.... Please help me out
by Corion (Patriarch) on Apr 22, 2009 at 07:00 UTC | |
by sandy1028 (Sexton) on Apr 22, 2009 at 07:26 UTC |