=over

=item seek FILEHANDLE,POSITION,WHENCE
X<seek> X<fseek> X<filehandle, position>

Sets FILEHANDLE's position, just like the C<fseek> call of C<stdio>.
FILEHANDLE may be an expression whose value gives the name of the
filehandle.  The values for WHENCE are C<0> to set the new position
I<in bytes> to POSITION, C<1> to set it to the current position plus
POSITION, and C<2> to set it to EOF plus POSITION (typically
negative).  For WHENCE you may use the constants C<SEEK_SET>,
C<SEEK_CUR>, and C<SEEK_END> (start of the file, current position, end
of the file) from the Fcntl module.  Returns C<1> upon success, C<0>
otherwise.

Note the I<in bytes>: even if the filehandle has been set to
operate on characters (for example by using the C<:encoding(utf8)> open
layer), tell() will return byte offsets, not character offsets
(because implementing that would render seek() and tell() rather slow).

If you want to position file for C<sysread> or C<syswrite>, don't use
C<seek>--buffering makes its effect on the file's system position
unpredictable and non-portable.  Use C<sysseek> instead.

Due to the rules and rigors of ANSI C, on some systems you have to do a
seek whenever you switch between reading and writing.  Amongst other
things, this may have the effect of calling stdio's clearerr(3).
A WHENCE of C<1> (C<SEEK_CUR>) is useful for not moving the file position:

    seek(TEST,0,1);

This is also useful for applications emulating C<tail -f>.  Once you hit
EOF on your read, and then sleep for a while, you might have to stick in a
seek() to reset things.  The C<seek> doesn't change the current position,
but it I<does> clear the end-of-file condition on the handle, so that the
next C<< <FILE> >> makes Perl try again to read something.  We hope.

If that doesn't work (some IO implementations are particularly
cantankerous), then you may need something more like this:

    for (;;) {
	for ($curpos = tell(FILE); $_ = <FILE>;
             $curpos = tell(FILE)) {
	    # search for some stuff and put it into files
	}
	sleep($for_a_while);
	seek(FILE, $curpos, 0);
    }

=back