1dynamic(3)            User Contributed Perl Documentation           dynamic(3)
2
3
4

NAME

6       PerlIO::via::dynamic - dynamic PerlIO layers
7

SYNOPSIS

9        open $fh, $fname;
10        $p = PerlIO::via::dynamic->new
11         (translate =>
12           sub { $_[1] =~ s/\$Filename[:\w\s\-\.\/\\]*\$/\$Filename: $fname\$/e},
13          untranslate =>
14           sub { $_[1] =~ s/\$Filename[:\w\s\-\.\/\\]*\$/\$Filename\$/});
15        $p->via ($fh);
16        binmode $fh, $p->via; # deprecated
17

DESCRIPTION

19       "PerlIO::via::dynamic" is used for creating dynamic PerlIO layers. It
20       is useful when the behavior or the layer depends on variables. You
21       should not use this module as via layer directly (ie :via(dynamic)).
22
23       Use the constructor to create new layers, with two arguments: translate
24       and untranslate. Then use "$p-"via ($fh)> to wrap the handle.  Once
25       <$fh> is destroyed, the temporary namespace for the IO layer will be
26       removed.
27
28       Note that PerlIO::via::dynamic uses the scalar fields to reference to
29       the object representing the dynamic namespace.
30

OPTIONS

32       translate
33           A function that translate buffer upon write.
34
35       untranslate
36           A function that translate buffer upon read.
37
38       use_read
39           Use "READ" instead of "FILL" for the layer.  Useful when caller
40           expect exact amount of data from read, and the "untranslate"
41           function might return different length.
42
43           By default "PerlIO::via::dynamic" creates line-based layer to make
44           "translate" implementation easier.
45

AUTHORS

47       Chia-liang Kao <clkao@clkao.org>
48
50       Copyright 2004 by Chia-liang Kao <clkao@clkao.org>.
51
52       This program is free software; you can redistribute it and/or modify it
53       under the same terms as Perl itself.
54
55       See <http://www.perl.com/perl/misc/Artistic.html>
56
57
58
59perl v5.36.0                      2023-01-20                        dynamic(3)
Impressum