1IO::Seekable(3pm) Perl Programmers Reference Guide IO::Seekable(3pm)
2
3
4
6 IO::Seekable - supply seek based methods for I/O objects
7
9 use IO::Seekable;
10 package IO::Something;
11 @ISA = qw(IO::Seekable);
12
14 "IO::Seekable" does not have a constructor of its own as it is intended
15 to be inherited by other "IO::Handle" based objects. It provides
16 methods which allow seeking of the file descriptors.
17
18 $io->getpos
19 Returns an opaque value that represents the current position of the
20 IO::File, or "undef" if this is not possible (eg an unseekable
21 stream such as a terminal, pipe or socket). If the fgetpos()
22 function is available in your C library it is used to implements
23 getpos, else perl emulates getpos using C's ftell() function.
24
25 $io->setpos
26 Uses the value of a previous getpos call to return to a previously
27 visited position. Returns "0 but true" on success, "undef" on
28 failure.
29
30 See perlfunc for complete descriptions of each of the following
31 supported "IO::Seekable" methods, which are just front ends for the
32 corresponding built-in functions:
33
34 $io->seek ( POS, WHENCE )
35 Seek the IO::File to position POS, relative to WHENCE:
36
37 WHENCE=0 (SEEK_SET)
38 POS is absolute position. (Seek relative to the start of
39 the file)
40
41 WHENCE=1 (SEEK_CUR)
42 POS is an offset from the current position. (Seek relative
43 to current)
44
45 WHENCE=2 (SEEK_END)
46 POS is an offset from the end of the file. (Seek relative
47 to end)
48
49 The SEEK_* constants can be imported from the "Fcntl" module if you
50 don't wish to use the numbers 0 1 or 2 in your code.
51
52 Returns 1 upon success, 0 otherwise.
53
54 $io->sysseek( POS, WHENCE )
55 Similar to $io->seek, but sets the IO::File's position using the
56 system call lseek(2) directly, so will confuse most perl IO
57 operators except sysread and syswrite (see perlfunc for full
58 details)
59
60 Returns the new position, or "undef" on failure. A position of
61 zero is returned as the string "0 but true"
62
63 $io->tell
64 Returns the IO::File's current position, or -1 on error.
65
67 perlfunc, "I/O Operators" in perlop, IO::Handle IO::File
68
70 Derived from FileHandle.pm by Graham Barr <gbarr@pobox.com>
71
72
73
74perl v5.30.1 2019-11-29 IO::Seekable(3pm)