=over
=item sysseek FILEHANDLE,POSITION,WHENCE
X X
Sets FILEHANDLE's system position I using L. FILEHANDLE may
be an expression whose value gives the name of the filehandle. The values
for WHENCE are C to set the new position to POSITION; C to set it
to the current position plus POSITION; and C to set it to EOF plus
POSITION, typically negative.
Note the emphasis on bytes: even if the filehandle has been set to operate
on characters (for example using the C<:encoding> I/O layer), the
L|/seek FILEHANDLE,POSITION,WHENCE>,
L|/tell FILEHANDLE>, and
L|/sysseek FILEHANDLE,POSITION,WHENCE>
family of functions use byte offsets, not character offsets,
because seeking to a character offset would be very slow in a UTF-8 file.
L|/sysseek FILEHANDLE,POSITION,WHENCE> bypasses normal
buffered IO, so mixing it with reads other than
L|/sysread FILEHANDLE,SCALAR,LENGTH,OFFSET> (for example
L|/readline EXPR> or
L|/read FILEHANDLE,SCALAR,LENGTH,OFFSET>),
L|/print FILEHANDLE LIST>, L|/write FILEHANDLE>,
L|/seek FILEHANDLE,POSITION,WHENCE>,
L|/tell FILEHANDLE>, or L|/eof FILEHANDLE> may cause
confusion.
For WHENCE, you may also use the constants C, C,
and C (start of the file, current position, end of the file)
from the L module. Use of the constants is also more portable
than relying on 0, 1, and 2. For example to define a "systell" function:
use Fcntl 'SEEK_CUR';
sub systell { sysseek($_[0], 0, SEEK_CUR) }
Returns the new position, or the undefined value on failure. A position
of zero is returned as the string C; thus
L|/sysseek FILEHANDLE,POSITION,WHENCE> returns
true on success and false on failure, yet you can still easily determine
the new position.
=back