Catmandu::Buffer(3pm)
π Catmandu::Buffer π
okay so bestie, welcome to Catmandu::Buffer β it's a base class for modules that need an array buffer. that's the whole vibe. it's giving "scaffolding, but make it chic" π«Ά
this page lives in the User Contributed Perl Documentation section, and it's filed under Catmandu::Buffer(3pm), iykyk.
β¨ SYNOPSIS β¨
here's the whole thing, copied with love (and zero edits, because we do NOT play with code):
package MyPackage;
use Moo;
with 'Catmandu::Buffer';
# Print only when the buffer is full...
sub print {
my ($self,$str) = @_;
if ($self->buffer_is_full) {
print join "\n" , @{ $self->buffer };
$self->clear_buffer;
}
$self->buffer_add($str);
}
package main;
my $x = MyPackage->new;
for (my $i = 0 ; $i < 1000 ; $i++) {
$x->print($x);
}
see how it works? you with 'Catmandu::Buffer' (Moo role energy π
), and then your print sub only actually prints when the buffer is full. the comment in the source literally says # Print only when the buffer is full... so that's the whole point, no cap. when it IS full you print join "\n" , @{ $self->buffer };, then $self->clear_buffer;, and either way you always $self->buffer_add($str); at the end. then in package main we make a MyPackage->new and loop for (my $i = 0 ; $i < 1000 ; $i++) calling $x->print($x);. iconic. runs 1000 times. periodt.
π ATTRIBUTES π
buffer
a ARRAY reference to the content of the buffer. yes, "a ARRAY", we're quoting the original grammar and we're not sorry, it's part of the lore. πΈ
buffer_size(MAX)
the maximum size of a buffer. so like, the cap. the limit. the "bestie we're full" moment. MAX is what you pass in. π
π¦ METHODS π¦
clear_buffer()
empty the buffer. poof. gone. β¨
buffer_used()
returns a true value when there is content in the buffer. so it's basically asking "is there anything in there??" and getting a yes or a nothing. π
buffer_is_full()
returns a true value when the buffer has reached its maximum capacity. this is the vibe check your print sub does before it dumps everything out. π₯
buffer_add($x)
adds $x to the buffer. that's it. that's the method. little king behavior π
π SEE ALSO π
Catmandu::Solr::Bag
go look at it, it's right there, be nosy. π
and that's the page, bestie!! this one was perl v5.40.1, dated 2026-01-24, and it's the Catmandu::Buffer(3pm) manpage β mwah, go buffer something responsibly π©·β¨
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· 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