4 XSLoader::load 'PerlIO::Via';
10 PerlIO::Via - Helper class for PerlIO layers implemented in perl
16 open($fh,"<:Via(Some::Package)",...);
20 The package to be used as a layer should implement at least some of the
21 following methods. In the method descriptions below I<$fh> will be
22 a reference to a glob which can be treated as a perl file handle.
23 It refers to the layer below. I<$fh> is not passed if the layer
24 is at the bottom of the stack, for this reason and to maintain
25 some level of "compatibility" with TIEHANDLE classes it is passed last.
27 As an example, in Perl release 5.8.0 the MIME::QuotedPrint module
28 defines the required TIEHANDLE methods so that you can say
30 use MIME::QuotedPrint;
31 open(my $fh, ">Via(MIME::QuotedPrint)", "qp");
35 =item $class->PUSHED([$mode][,$fh])
37 Should return an object or the class. (Compare TIEHANDLE.)
40 =item $obj->POPPED([$fh])
42 Optional - layer is about to be removed.
44 =item $class->OPEN($path,$mode[,$fh])
48 =item $class->FDOPEN($fd)
52 =item $class->SYSOPEN($path,$imode,$perm,$fh)
56 =item $obj->FILENO($fh)
58 Returns a numeric value for Unix-like file descriptor. Return -1 if
59 there isn't one. Optional. Default is fileno($fh).
61 =item $obj->READ($buffer,$len,$fh)
63 Returns the number of octets placed in $buffer (must be less than or
64 equal to $len). Optional. Default is to use FILL instead.
66 =item $obj->WRITE($buffer,$fh)
68 Returns the number of octets from buffer that have been sucessfully written.
72 Should return a string to be placed in the buffer. Optional. If not
73 provided must provide READ or reject handles open for reading in
76 =item $obj->CLOSE($fh)
78 Should return 0 on success, -1 on error.
81 =item $obj->SEEK($posn,$whence,$fh)
83 Should return 0 on success, -1 on error.
84 Optional. Default is to fail, but that is likely to be changed.
89 Optional. Default to be determined.
91 =item $obj->UNREAD($buffer,$fh)
93 Returns the number of octets from buffer that have been sucessfully
94 saved to be returned on future FILL/READ calls. Optional. Default is
95 to push data into a temporary layer above this one.
97 =item $obj->FLUSH($fh)
99 Flush any buffered write data. May possibly be called on readable
100 handles too. Should return 0 on success, -1 on error.
102 =item $obj->SETLINEBUF($fh)
106 =item $obj->CLEARERR($fh)
110 =item $obj->ERROR($fh)
112 Optional. Returns error state. Default is no error until a mechanism
113 to signal error (die?) is worked out.
117 Optional. Returns end-of-file state. Default is function of return
118 value of FILL or READ.