Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

seek

Sets the read/write position in a filehandle.

Repositions the file pointer for the given filehandle. The WHENCE argument selects the reference point: 0 (SEEK_SET) for the beginning of the file, 1 (SEEK_CUR) for the current position, and 2 (SEEK_END) for the end of the file. Returns 1 on success, 0 on failure.

Also accepts IO::Handle / IO::File objects (blessed hashrefs with __fh_id).

Synopsis

seek($fh, $offset, 0);   # SEEK_SET — absolute position
seek($fh, $offset, 1);   # SEEK_CUR — relative to current
seek($fh, $offset, 2);   # SEEK_END — relative to end

See Also

tell, sysseek, Fcntl