Badger...:Chain(3pm)
π Badger::Codec::Chain β bestie edition π
okay so this is Badger::Codec::Chain, from the User Contributed Perl Documentation, living in section 3pm of your friendly neighbourhood man pages. she's a lil module that lets you stack codecs on top of each other like it's a fit check. β¨
β¨ NAME β¨
Badger::Codec::Chain β encode/decode data using multiple codecs π¦
β¨ SYNOPSIS β¨
use Badger::Codec::Chain;
# compact form
my $codec = Badger::Codec::Chain->new('storable+base64');
# explicit form
my $codec = Badger::Codec::Chain->new('storable', 'base64');
# encode/decode data using codec chain
my $enc = $codec->encode({ pi => 3.14, e => 2.718 });
my $dec = $codec->decode($encoded);
β¨ DESCRIPTION β¨
so basically π this module is a subclass of Badger::Codec, and what it does is chain together any number of other codec modules. that's it. that's the whole vibe. one codec? cute. ten codecs? iconic. she stacks them. periodt. π
β¨ METHODS β¨
π new(@codecs)
constructor method, bestie β she makes you a brand new codec chain β¨. the codecs can be specified by name or as references to Badger::Codec objects. whatever you're feeling, honestly.
# by name
my $codec = Badger::Codec::Chain->new('storable', 'base64');
# by object reference
my $codec = Badger::Codec::Chain->new(
Badger::Codec->codec('storable'),
Badger::Codec->codec('base64'),
);
you can also use the compact form where multiple codec names are separated by "+". yes the plus sign. she's doing math but make it codecs. π§
# compact form
my $codec = Badger::Codec::Chain->new('storable+base64');
π encode($data)
encodes the data referenced by the first argument using all the codecs in the chain. every single one. no skips. π
$encoded = $codec->encode($data);
π decode($html)
decodes the encoded data passed as the first argument using all the codecs in the chain in reverse order. yes reverse. she's retracing her steps, main character energy. π«
$decoded = $codec->decode($encoded);
π encoder()
returns a reference to a subroutine which performs the encoding operation. like, here's a lil function you can hold in your hand. π«Ά
π decoder()
returns a reference to a subroutine which performs the decoding operation. same energy, opposite direction. π¦
β¨ INTERNAL METHODS β¨
π coder(@coders)
internal method to construct an encoder or decoder subroutine for a codec chain. that's it, that's the tea β it's internal, you're not meant to be here, but we love a peek behind the curtain. π
β¨ AUTHOR β¨
Andy Wardley <http://wardley.org/> β king behaviour tbh π
β¨ COPYRIGHT β¨
Copyright (C) 2005-2009 Andy Wardley. All rights reserved.
β¨ SEE ALSO β¨
Badger::CodecsBadger::Codec
go read those too bestie, iykyk π
and that's the whole page!! no cap. this beauty shipped as perl v5.36.0, dated 2023-08-28. slay, stay safe, and hydrate before you chain too many codecs ππ
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-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