in reply to Can read() return less than LENGTH bytes?

If the file is set to be non-bocking, then when you read from it, it gives you as much as it can (up to LENGTH) but will return control back to the program immediately. This allows you to communiate on several network sockets at once for example. Without it you could get stuck waiting for LENGTH bytes to arrive.

Also, on some Unixes, if a signal arrives then it can interrupt the system call and cause it to return prematurely (with $! set to EAGAIN which means that there was no error and you should try the call again). I tried to construct an example for this but it didn't work, possibly because perl handles signals in a reasonably robust manner and restarts the read for you automatically.

That said, it seems that you don't need non-blocking IO or signals to get an example using sysread

sysread(STDIN, $buffer, 1000); print "read ".length($buffer). " chars\n$buffer\n";
when I type something in and hit enter the sysread returns immediately with far less than 1000 chars.