in reply to Pipes: Is it possible for a child to just read one line?
There are systems with record-based pipes (VMS in particular and I think Win32 has something like that for pipes) where something like this could work but only if you write each record with a separate call to write(1); such as using $| like you did but doing print WRITER "$_\n" and moving your foreach to inside of your while loop.
For byte-stream pipes, this could work if you used fixed-length records (and unbuffered I/O on both sides).
If you want to use variable-length "records" portably, then you'll need to use a more complicated approach. You can have the dispatcher write the record length (in a fixed number of bytes) and then write the data for that record. Each client can lock a semaphore, read the fixed-length data, pull the record length out of it, read the variable-length record, then unlock the semaphore.
- tye
|
|---|