1N/AIO::Seekable - supply seek based methods for I/O objects 1N/A package IO::Something; 1N/A @ISA = qw(IO::Seekable); 1N/AC<IO::Seekable> does not have a constructor of its own as it is intended to 1N/Abe inherited by other C<IO::Handle> based objects. It provides methods 1N/Awhich allow seeking of the file descriptors. 1N/AReturns an opaque value that represents the current position of the 1N/AIO::File, or C<undef> if this is not possible (eg an unseekable stream such 1N/Aas a terminal, pipe or socket). If the fgetpos() function is available in 1N/Ayour C library it is used to implements getpos, else perl emulates getpos 1N/Ausing C's ftell() function. 1N/AUses the value of a previous getpos call to return to a previously visited 1N/Aposition. Returns "0 but true" on success, C<undef> on failure. 1N/ASee L<perlfunc> for complete descriptions of each of the following 1N/Asupported C<IO::Seekable> methods, which are just front ends for the 1N/Acorresponding built-in functions: 1N/A=item $io->seek ( POS, WHENCE ) 1N/ASeek the IO::File to position POS, relative to WHENCE: 1N/A=item WHENCE=0 (SEEK_SET) 1N/APOS is absolute position. (Seek relative to the start of the file) 1N/A=item WHENCE=1 (SEEK_CUR) 1N/APOS is an offset from the current position. (Seek relative to current) 1N/A=item WHENCE=2 (SEEK_END) 1N/APOS is an offset from the end of the file. (Seek relative to end) 1N/AThe SEEK_* constants can be imported from the C<Fcntl> module if you 1N/Adon't wish to use the numbers C<0> C<1> or C<2> in your code. 1N/AReturns C<1> upon success, C<0> otherwise. 1N/A=item $io->sysseek( POS, WHENCE ) 1N/ASimilar to $io->seek, but sets the IO::File's position using the system 1N/Acall lseek(2) directly, so will confuse most perl IO operators except 1N/Asysread and syswrite (see L<perlfunc> for full details) 1N/AReturns the new position, or C<undef> on failure. A position 1N/Aof zero is returned as the string C<"0 but true"> 1N/AReturns the IO::File's current position, or -1 on error. 1N/AL<perlop/"I/O Operators">, 1N/A# XXX we can't get these from IO::Handle or we'll get prototype 1N/A# mismatch warnings on C<use POSIX; use IO::File;> :-( 1N/A @_ ==
3 or croak 'usage: $io->seek(POS, WHENCE)';
1N/A seek($_[
0], $_[
1], $_[
2]);
1N/A @_ ==
3 or croak 'usage: $io->sysseek(POS, WHENCE)';
1N/A sysseek($_[
0], $_[
1], $_[
2]);
1N/A @_ ==
1 or croak 'usage: $io->tell()';