Catman...x::Has(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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