# PerlIO::via
π¦ min
Write a PerlIO layer in Perl: open with `:via(MyClass)` and I/O dispatches to your class.
This is a PerlIO layer implementation that delegates I/O operations to a
Perl class. When a handle is opened with `:via(MyClass)`, each PerlIO
vtable method (read, write, fill, flush, etc.) calls the corresponding
Perl method on the class object (MyClass->WRITE, MyClass->READ, etc.).
`via.xs` struct PerlIOVia extends \_PerlIO (base) with:
stash β HV\* for the class package
obj β SV\* the blessed object (or class name)
var β SV\* buffer for FILL results
cnt β SSize_t byte count remaining in var
io β IO\* for the filehandle to layer below
fh β SV\* reference to the GV wrapping io
PUSHED..UTF8 β CV\* cached method lookups (one per via method)
The MYMethod(x) macro expands to `"METHODNAME", &s->x` β passing both the
string name and a pointer to the cached CV\* slot.
The BOOT section registers the βviaβ PerlIO layer via PerlIO_define_layer.
## Functions
### Other Functions
#### `pop_result`
Pop a single SV result off the Perl stack (equivalent of SPAGAIN; POPs). Returns a p5api SV\*.