Your skill will accomplish
what the force of many cannot
while reading a file, transfer the same data to two different processes.by avanta (Beadle)
|on May 20, 2010 at 15:01 UTC||Need Help??|
avanta has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to read a log file one transaction (block of lines) at a time. Now I wish to deliver this data to two separate processes by forking. Following is the code I tried to come up with.
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.
This is where my problem starts. I wish to read the log file only once and send the data to two different processes for processing. And, also the limitation is that I cannot read all the transactions in the log file at once and send it for processing, I have to read it transaction by transaction.
An example of log file content can be:
So now $record will have
as first transaction and so on.
It would be great if any one can tell me how I can achieve my goal.