| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
PerlIO::rewindable - I/O layer to allow rewinding of streams |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
binmode \*STDIN, ":rewindable"; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This PerlIO layer makes it possible to rewind an input stream that would |
|
12
|
|
|
|
|
|
|
otherwise not be rewindable, such as a TTY or a pipe from another process. |
|
13
|
|
|
|
|
|
|
Reads pass through this layer, reading from the underlying stream, but |
|
14
|
|
|
|
|
|
|
this layer keeps a copy of everything that is read. C can be used |
|
15
|
|
|
|
|
|
|
to move around within the saved data to reread it. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Cs may be relative (whence=1, C) or absolute (whence=1, |
|
18
|
|
|
|
|
|
|
C). For the purposes of absolute seeking, position 0 is |
|
19
|
|
|
|
|
|
|
wherever the stream was when this layer was pushed. C can be |
|
20
|
|
|
|
|
|
|
used to read this absolute position. End-relative Cs (whence=2, |
|
21
|
|
|
|
|
|
|
C) are not supported, even if the underlying stream has |
|
22
|
|
|
|
|
|
|
signalled EOF. If the underlying stream is actually seekable, for |
|
23
|
|
|
|
|
|
|
example if it is actually a regular file, that aspect of it is hidden |
|
24
|
|
|
|
|
|
|
by the rewindability layer. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Seeking both backwards and forwards is supported within the saved data |
|
27
|
|
|
|
|
|
|
that was previously read. Seeking forwards past the last data read from |
|
28
|
|
|
|
|
|
|
the underlying stream is not currently supported, but this may change |
|
29
|
|
|
|
|
|
|
in the future. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Writing is not permitted through the rewindability layer. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
If this layer is popped, it attempts to maintain any rewound state, by |
|
34
|
|
|
|
|
|
|
generating a temporary PerlIO layer to hold pending data. This is then |
|
35
|
|
|
|
|
|
|
subject to normal PerlIO behaviour, which does not strongly maintain |
|
36
|
|
|
|
|
|
|
consistency of such rewinding. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
package PerlIO::rewindable; |
|
41
|
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
4833
|
{ use 5.008001; } |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
53
|
|
|
43
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
44
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
77
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = "0.001"; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
require XSLoader; |
|
49
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
L, |
|
54
|
|
|
|
|
|
|
L, |
|
55
|
|
|
|
|
|
|
L, |
|
56
|
|
|
|
|
|
|
L |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 AUTHOR |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Andrew Main (Zefram) |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Copyright (C) 2010, 2011 Andrew Main (Zefram) |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 LICENSE |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
69
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |