I used read specifically because it is more flexible than getc
I don't see how read is more flexible than getc at reading available characters in the pipe. sysread is more flexible since it can read multiple characters in addition to reading a single character. This also makes it much faster IIRC.
I used read specifically because it [...] does interact properly with buffering if there is any.
That means you specifically didn't chose sysread because it doesn't interact properly with buffered IO, yet one is much more likely to encounter unbuffered IO than buffered IO when dealing with pipes (because the former solves the OP's problem and it's required by select).
but sysread may be preferable if bypassing buffers is desired as a rule.
That's backwards. I didn't use sysread to bypasses buffers, buffers aren't used because I used sysread. In the rare circumstance that other code reads from the pipe, non-buffered IO will have to be used there too, but that's not likely to be a problem. In the much more likely circumstance that select is used on the pipe, you'd need sysread anyway.
As an aside, although there is for perl 5.10.1 and 5.12.0 a note at the bottom of the entry for sysread in the perldocs about UTF and characters,
Basically, it says sysread will work with character streams as well as byte streams. I don't see why I should be pointing that out.
In reply to Re^6: Nested line buffered output
by ikegami
in thread Nested line buffered output
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |