dynamic(3pm)
πΈ NAME πΈ
okay so this is the dynamic(3pm) page from the User Contributed Perl Documentation, and it's literally all about PerlIO::via::dynamic β dynamic PerlIO layers, bestie. that's the whole vibe. π
β¨ SYNOPSIS β¨
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
bestie that last line?# deprecated. it's giving "old money, no thanks." use$p->via ($fh)instead, periodt. π
π¦ DESCRIPTION π¦
so PerlIO::via::dynamic is what you use when you wanna create dynamic PerlIO layers. it's the moment when the behavior of the layer β or the layer itself β depends on variables. that's its whole thing, and it ate. π₯
lowkey important: do NOT use this module as a via layer directly (like, :via(dynamic)). that's not it. that is not the assignment. π
the move is: use the constructor to make new layers, and it takes two arguments β translate and untranslate. then you use $p->via ($fh) to wrap the handle. and once $fh is destroyed, the temporary namespace for the IO layer gets removed too β it cleans up after itself, main character energy honestly. β¨
also note, fr fr: PerlIO::via::dynamic uses the scalar fields to reference to the object representing the dynamic namespace. iykyk. π
π OPTIONS π
translateβ a function that translate buffer upon write. βοΈuntranslateβ a function that translate buffer upon read. πuse_readβ useREADinstead ofFILLfor the layer. useful when the caller expects an exact amount of data from read, and theuntranslatefunction might return a different length. π€
by defaultPerlIO::via::dynamiccreates a line-based layer, and that's on purpose β it makes implementingtranslateeasier. cute of it, honestly. π
π AUTHORS π
Chia-liang Kao <clkao@clkao.org>
π COPYRIGHT π
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>
and that's the whole page, bestie π«Ά this one's perl v5.36.0, dated 2022-11-20, and yeah it's dynamic(3pm) β go forth and layer dynamically, you absolute icon πβ¨πΈ
π¦ where this page comes from
- debian bookworm: libperlio-via-dynamic-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libperlio-via-dynamic-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libperlio-via-dynamic-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libperlio-via-dynamic-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libperlio-via-dynamic-perl 0.14-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms