avanta has asked for the wisdom of the Perl Monks concerning the following question:
In the code "$fp->getline()" is reading the transactions and storing in "$record" in a loop and by conditional forking I transferred "$record" to two different functions in different processes. But here as you can see for first transaction the reading from log file is done only once but for subsequent transactions this is done twice as we have two processes at that moment.my $flag=0; my $pid; while ($record = $fp->getline()) { if(flag == 0) { $flag=1; $pid=fork(); } else { if($pid == 0) { function1($record); } else { function2($record); } } }
So now $record will haveDate: 2010-05-01 location: NZ Date: 2010-05-02 location: AU Date: 2010-05-03 location: IN
|
|---|