1IO::Handle::Prototype::UFsaelrlbCaocnkt(r3ipbmu)ted PerlIOD:o:cHuamnednltea:t:iPornototype::Fallback(3pm)
2
3
4

NAME

6       IO::Handle::Prototype::Fallback - Create IO::Handle like objects using
7       a set of callbacks.
8

SYNOPSIS

10           my $fh = IO::Handle::Prototype::Fallback->new(
11               getline => sub {
12                   my $fh = shift;
13
14                   ...
15               },
16           );
17

DESCRIPTION

19       This class provides a way to define a filehandle based on callbacks.
20
21       Fallback implementations are provided to the extent possible based on
22       the provided callbacks, for both writing and reading.
23

SPECIAL CALLBACKS

25       This class provides two additional methods on top of IO::Handle,
26       designed to let you implement things with a minimal amount of baggage.
27
28       The fallback methods are all best implemented using these, though these
29       can be implemented in terms of Perl's standard methods too.
30
31       However, to provide the most consistent semantics, it's better to do
32       this:
33
34           IO::Handle::Prototype::Fallback->new(
35               __read => sub {
36                   shift @array;
37               },
38           );
39
40       Than this:
41
42           IO::Handle::Prototype::Fallback->new(
43               getline => sub {
44                   shift @array;
45               },
46           );
47
48       Because the fallback implementation of "getline" implements all of the
49       extra crap you'd need to handle to have a fully featured
50       implementation.
51
52       __read
53           Return a chunk of data of any size (could use $/ or not, it depends
54           on you, unlike "getline" which probably should respect the value of
55           $/).
56
57           This avoids the annoying "substr" stuff you need to do with "read".
58
59       __write $string
60           Write out a string.
61
62           This is like a simplified "print", which can disregard $, and "$\"
63           as well as multiple argument forms, and does not have the extra
64           "substr" annoyance of "write" or "syswrite".
65

WRAPPING

67       If you provide a single reading related callback ("__read", "getline"
68       or "read") then your callback will be used to implement all of the
69       other reading primitives using a string buffer.
70
71       These implementations handle $/ in all forms ("undef", ref to number
72       and string), all the funny calling conventions for "read", etc.
73

FALLBACKS

75       Any callback that can be defined purely in terms of other callbacks in
76       a way will be added. For instance "getc" can be implemented in terms of
77       "read", "say" can be implemented in terms of "print", "print" can be
78       implemented in terms of "write", "write" can be implemented in terms of
79       "print", etc.
80
81       None of these require special wrapping and will always be added if
82       their dependencies are present.
83

GLOB OVERLOADING

85       When overloaded as a glob a tied handle will be returned. This allows
86       you to use the handle in Perl's IO builtins. For instance:
87
88           my $line = <$fh>
89
90       will not call the "getline" method natively, but the tied interface
91       arranges for that to happen.
92
93
94
95perl v5.34.0                      2022-01-2I1O::Handle::Prototype::Fallback(3pm)
Impressum