sysread

sysreadFILEHANDLE,SCALAR,LENGTH,OFFSETsysreadFILEHANDLE,SCALAR,LENGTH
This function tries to read LENGTH characters
of data into variable SCALAR from the
specified FILEHANDLE using a low-level
syscall, read(2). The function returns the number
of characters read, or 0 at EOF.[251] The sysread function
returns undef on error.
SCALAR will grow or shrink to the length
actually read. The OFFSET, if specified, says
where in the string to start putting the characters so that you can read
into the middle of a string that’s being used as a buffer. For an
example of using OFFSET, see syswrite. An exception is raised if
LENGTH is negative or if
OFFSET points outside the string.
If the filehandle has no encoding layer, then the characters read in are no larger than 255, so they are effectively bytes.
Be prepared to handle the problems (like interrupted syscalls)
that standard I/O normally handles
for you. Because it bypasses standard I/O, do not mix sysread with other kinds of reads, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access