Perl sysread Function
This function is the equivalent of the C/operating system function read() because it bypasses the buffering system employed by functions like print, read, and seek, it should only be used with the corresponding syswrite and sysseek functions.
It read LENGTH bytes from FILEHANDLE, placing the result in SCALAR. If OFFSET is specified, then data is written to SCALAR from OFFSET bytes, effectively appending the information from a specific point. If OFFSET is negative, it starts from the number of bytes specified counted backward from the end of the string.
Following is the simple syntax for this function:
sysread FILEHANDLE, SCALAR, LENGTH, OFFSET sysread FILEHANDLE, SCALAR, LENGTH
This function returns undef on error, 0 at end of file and Integer, number of bytes read on success.
Following is the example code showing its basic usage:
When above code is executed, it produced following result