Catman...erlcode(3pm)
π NAME π
Catmandu::Fix::perlcode β execute Perl code as a fix function β¨
πΈ DESCRIPTION πΈ
okay bestie, listen. this fix is for when you're living in the Catmandu fix language but you're also feeling a little main character and you wanna run your own Perl script in there. so you just do this:
perlcode(myscript.pl)
and that's it, that's the whole vibe. π
now β the script (in our lil example it's called myscript.pl) has to return a code reference. no exceptions, bestie, it's giving contract. π«Ά
sub {
my $data = shift;
$data->{testing} = 1 ; # modify the item
return $data; # and return the data
}
see how it takes $data, messes with it, and hands it back? that's the whole personality. modify the item, then return the data. π
and if you're not using the fix language (iconic of you honestly), this:
my $fixer = Catmandu::Fix->new( fixes => [ do 'myscript.pl' ] );
$fixer->fix( $item );
is roughly equivalent to:
my $code = do 'myscript.pl';
$item = $code->( $item )
roughly!! not exactly, don't come for me, that's literally what the manpage says. π
π the caching thing (iykyk)
all scripts are cached based on their filename, so if you use this fix a bunch of times, each given script only gets loaded once. we love an efficient queen. β¨π
π¦ the second value (this one's important fr fr)
the code reference gets passed a second value so you can reject selected items β the same kind of energy as with see Catmandu::Fix::reject:
sub {
my ($data, $reject) = @_;
if ($data->{my_field} eq 'OK') {
return $data; # return the data and continue processing
}
else {
return $reject; # return the reject flag to ignore this record
}
}
so like β return $data and the record keeps going, return $reject and that record gets ignored, bye bye, not our problem anymore. π that's the whole bit. periodt. π
β¨ SEE ALSO β¨
Catmandu::Fix::codeCatmandu::Fix::cmd
and that's the tea bestie π this was written for perl v5.40.1, dated 2026-01-24, straight out of the User Contributed Perl Documentation collection, filed under Catman...erlcode(3pm) β slay, go write a fix, ily ππ§β¨
π¦ 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