IO::Co...Brotli(3pm)
π NAME π
IO::Compress::Brotli β bestie, this one writes Brotli buffers and streams. It's the compression girlie π
β¨ SYNOPSIS β¨
use IO::Compress::Brotli;
# compress a buffer
my $encoded = bro $encoded;
# compress a stream
my $bro = IO::Compress::Brotli->create;
while(have_input()) {
my $block = get_input_block();
my $encoded_block = $bro->compress($block);
handle_output_block($encoded_block);
}
# Need to finish the steam
handle_output_block($bro->finish());
π¦ DESCRIPTION π¦
IO::Compress::Brotli is a module that compressed Brotli buffers and streams. Okay so, real talk: despite the name, it is not a subclass of IO::Compress::Base and it does not implement that interface. That's getting fixed in a future release, promise π€
π One-shot interface
If you've got the whole buffer sitting in a Perl scalar, just use the bro function. Easy. Iconic. No assembly required.
bro($input, $quality, $window)β takes a whole uncompressed buffer as input and hands you back the compressed data, using the quality and window params you passed. If you skip the quality and window args, the defaults get used (they're described down in the object-oriented interface section, iykyk). This one is exported by default π«Ά
π Streaming interface
Wanna chew through the data in blocks instead? Then it's the object oriented interface for you, bestie. Here are the methods available:
IO::Compress::Brotli->createβ returns anIO::Compress::Brotliinstance. Heads up though, one single instance can't be used to decompress multiple streams. One stream per instance, she's monogamous π$bro->window($window)β sets the window parameter on the brotli encoder. Defaults toBROTLI_DEFAULT_WINDOW(22).$bro->quality($quality)β sets the quality parameter on the brotli encoder. Defaults toBROTLI_DEFAULT_QUALITY(11).$bro->mode($mode)β sets the brotli encoder mode. It can be any of"generic","text"or"font". Defaults to"generic".$bro->compress($block)β takes a block of uncompressed data and gives you back a block of compressed data. Dies on error. No chill, no mercy π$bro->flush()β flushes any pending output out of the encoder. Like clearing your drafts folder, but make it compression πΈ$bro->finish()β tells the encoder to start the finish operation, and flushes whatever compressed output is still hanging around.
Once finish gets called, the encoder cannot be used to compress any more content. She's done, she's retired, the era is over π
β οΈ NOTE: calling finish is required. Skip it and the output might never get flushed, and it'll be missing its termination marks. Don't do that to your data babes, it's giving incomplete file π
π SEE ALSO π
- Brotli Compressed Data Format Internet-Draft: <https://www.ietf.org/id/draft-alakuijala-brotli-08.txt>
- Brotli source code: <https://github.com/google/brotli/>
π AUTHOR π
Marius Gavrilescu, <marius@ieval.ro>
The encoder bindings, the modernisation of the decoder bindings, and a clean up of the overall project were contributed by β absolute legends, every single one:
- Quim Rovira, <quim@rovira.cat>
- Γvar ArnfjΓΆrΓ° Bjarmason, <avarab@gmail.com>
- Marcell SzathmΓ‘ri
- Mattia Barbon, <mattia@barbon.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2015-2018 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.20.2 or, at your option, any later version of Perl 5 you may have available.
okay that's the whole page bestie, mwah π«Ά This was perl v5.42.3, dated 2026-08-19, and it's the IO::Compress::Brotli(3pm) page from the User Contributed Perl Documentation. Go compress something cute, and don't forget your finish β¨
π¦ where this page comes from
- ubuntu stonking: libio-compress-brotli-perl 0.019000-1build1 Β· 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