Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

sysread

Performs an unbuffered read directly from the OS file descriptor.

Reads up to LENGTH bytes from the filehandle into BUFFER using the underlying read(2) system call, bypassing Perl’s buffered I/O layer. When OFFSET is given, data is placed starting at that byte position within the buffer.

Returns the number of bytes actually read (which may be less than LENGTH), 0 at end-of-file, or undef on error (with $! set to the OS errno).

Warning: Do not mix sysread with buffered I/O (read, readline, <>) on the same filehandle.

Synopsis

$n = sysread($fh, $buf, $length);
$n = sysread($fh, $buf, $length, $offset);

See Also

read, syswrite, sysseek