sysseek

sysseekFILEHANDLE,POSITION,WHENCE
This function sets FILEHANDLE’s
system position using the syscall lseek(2). It
bypasses standard I/O, so mixing this with reads (other than sysread), print, write, seek, tell,
or eof may (and probably shall) cause
confusion. FILEHANDLE may be an expression
whose value gives the name of the filehandle. The values for
WHENCE are 0 to set the new position to
POSITION bytes into the file, 1 to set it to the current position plus
POSITION, and 2 to set it to EOF plus
POSITION bytes (typically negative). For
WHENCE, you may use the constants SEEK_SET, SEEK_CUR, and SEEK_END from the standard IO::Seekable and POSIX modules, or from the Fcntl module, which is more portable and convenient.
This function returns the new position in bytes, or undef on failure. A position of zero is
returned as the special string “0 but
true”, which can be used numerically without producing
warnings or having to mess around with //
die instead of the more customary ||
die.
Warning: POSITION is in bytes
not characters, no matter whether there should happen to be any encoding
layer on the filehandle. However, all functions in Perl that read from
files do go through any encoding layer, and you can therefore read a partial “character” and wind up with an invalid Perl string. ...
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