Catman...x::Has(3pm)
π Catman...x::Has(3pm) π
okay bestie, so like β this is Catmandu::Fix::Has, part of the User Contributed Perl Documentation (iykyk), and it's literally the helper class for creating Fix-es with (optional) parameters. she's the glue. the moment. the β¨ infrastructure β¨.
πΈ NAME πΈ
Catmandu::Fix::Has β helper class for creating Fix-es with (optional) parameters π
like, she doesn't do the whole thing herself, she just hands you the tools so your Fix can take arguments. no cap.
β¨ SYNOPSIS β¨
here's the vibe, look at her go:
package Catmandu::Fix::foo;
use Moo;
use Catmandu::Fix::Has;
has greeting => (fix_arg => 1); # required parameter 1
has message => (fix_arg => 1); # required parameter 2
has eol => (fix_opt => 1 , default => sub {'!'} ); # optional parameter 'eol' with default '!'
sub fix {
my ($self,$data) = @_;
print STDERR $self->greeting . ", " . $self->message . $self->eol . "\n";
$data;
}
1;
not me writing a whole Fix in like nine lines π«Ά iconic behaviour honestly.
π¦ PARAMETERS π¦
π
fix_arg
Required argument when set to 1. so if you flip that switch, your Fix is demanding β she will not run without it. The Fix containing the code fragment below needs two arguments:
use Catmandu::Fix::Has;
has message => (fix_arg => 1); # required parameter 1
has number => (fix_arg => 1); # required parameter 2
two args. no more, no less, no negotiating. periodt. π
now β when the fix_arg is set to 'collect', then all arguments are read into an array. The Fix containing the code fragment below needs at least 1 or more arguments. All arguments will get collected into the messages array:
use Catmandu::Fix::Has;
has messages => (fix_arg => 'collect'); # required parameter
okay so this one's giving "hoard every argument into one array" energy and honestly? valid. π
π fix_opt
Optional named argument when set to 1. this one's chill β she'll take it or leave it, but the door is open. The Fix containing the code fragment below can have two optional arguments message: ..., number: ...:
use Catmandu::Fix::Has;
has message => (fix_opt => 1); # optional parameter 1
has number => (fix_opt => 1); # optional parameter 2
optional named args, bestie. lowkey the most polite feature in the whole file. π§
and when the fix_opt is set to 'collect', then all optional argument are read into an array. The Fix containing the code fragment below needs at least 1 or more arguments. All arguments will get collected into the options array:
use Catmandu::Fix::Has;
has options => (fix_opt => 'collect'); # optional parameter
so yeah, 'collect' works on both of them and it's just out here gathering up your args like it's got main character energy in an array. π
π₯ SEE ALSO π₯
Catmandu::Fixβ go read her next, she's the whole reason this page exists fr fr
π a lil reminder bestie:fix_arg= mandatory,fix_opt= optional, and'collect'scoops everything into an array on either one. those are the three things you actually gotta remember. slay. π
and that's the whole page!! π¦ this one came from perl v5.40.1, dated 2026-01-24, and yes she's still filed under Catman...x::Has(3pm) β go forth and write iconic Fix-es, bestie πβ¨
π¦ 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