PerlIO::via::dynamic - dynamic PerlIO layers
open $fh, $fname; $p = PerlIO::via::dynamic->new (translate => sub { $_[1] =~ s/\$Filename[:\w\s\-\.\/\\]*\$/\$Filename: $fname\$/e}, untranslate => sub { $_[1] =~ s/\$Filename[:\w\s\-\.\/\\]*\$/\$Filename\$/}); $p->via ($fh); binmode $fh, $p->via; # deprecated
PerlIO::via::dynamic is used for creating dynamic PerlIO layers. It is useful when the behavior or the layer depends on variables. You should not use this module as via layer directly (ie :via(dynamic)).
PerlIO::via::dynamic
Use the constructor to create new layers, with two arguments: translate and untranslate. Then use $p-via ($fh)> to wrap the handle. Once <$fh> is destroyed, the temporary namespace for the IO layer will be removed.
$p-
Note that PerlIO::via::dynamic uses the scalar fields to reference to the object representing the dynamic namespace.
A function that translate buffer upon write.
A function that translate buffer upon read.
Use READ instead of FILL for the layer. Useful when caller expect exact amount of data from read, and the untranslate function might return different length.
READ
FILL
untranslate
By default PerlIO::via::dynamic creates line-based layer to make translate implementation easier.
translate
Chia-liang Kao <clkao@clkao.org>
Copyright 2004 by Chia-liang Kao <clkao@clkao.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install PerlIO::via::dynamic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlIO::via::dynamic
CPAN shell
perl -MCPAN -e shell install PerlIO::via::dynamic
For more information on module installation, please visit the detailed CPAN module installation guide.