Perl seek Function

Advertisements


Description

This function moves to a specified position in a file. You can move relative to the beginning of the file (WHENCE = 0), the current position (WHENCE = 1), or the end of the file (WHENCE = 2). This function is mainly used with fixed length records to randomly access specific records of the file.

For WHENCE you may use the constants SEEK_SET , SEEK_CUR , and SEEK_END (start of the file, current position, end of the file) from the Fcntl module.

This function is similar to Unix seek() system call.

Syntax

Following is the simple syntax for this function:

seek FILEHANDLE,POSITION,WHENCE

Return Value

This function

Example

Following is the example code showing its basic usage:


When above code is executed, it produced following result




Advertisements
Advertisements