Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Fixed-length unbuffered input ...Fixed-length unbuffered output ... (Berikutnya)
Input and output functions

Position I/O pointer on handle used with sysread and syswrite

Daftar Isi

  • sysseek FILEHANDLE,POSITION,WHENCE

    Sets FILEHANDLE's system position in bytes using lseek(2). FILEHANDLE maybe an expression whose value gives the name of the filehandle. The valuesfor WHENCE are 0 to set the new position to POSITION; 1 to set the itto the current position plus POSITION; and 2 to set it to EOF plusPOSITION, typically negative.

    Note the in bytes: even if the filehandle has been set to operateon characters (for example by using the :encoding(utf8) I/O layer),tell() will return byte offsets, not character offsets (becauseimplementing that would render sysseek() unacceptably slow).

    sysseek() bypasses normal buffered IO, so mixing it with reads otherthan sysread (for example <> or read()) print, write,seek, tell, or eof may cause confusion.

    For WHENCE, you may also use the constants SEEK_SET, SEEK_CUR,and SEEK_END (start of the file, current position, end of the file)from the Fcntl module. Use of the constants is also more portablethan relying on 0, 1, and 2. For example to define a "systell" function:

    1. use Fcntl 'SEEK_CUR';
    2. sub systell { sysseek($_[0], 0, SEEK_CUR) }

    Returns the new position, or the undefined value on failure. A positionof zero is returned as the string "0 but true"; thus sysseek returnstrue on success and false on failure, yet you can still easily determinethe new position.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Fixed-length unbuffered input ...Fixed-length unbuffered output ... (Berikutnya)