Catman...dition(3pm)

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

πŸ¦‹ Catman...dition(3pm) πŸ’…

okay so bestie, welcome to the Catman...dition(3pm) page β€” it lives in section 3pm of the User Contributed Perl Documentation, and it's literally the blueprint for every single conditional in Catmandu. no cap. let's get into it 🫢


✨ NAME ✨

Catmandu::Fix::Condition β€” the Role for all Catmandu::Fix conditionals. it's giving "everyone who wants to be a condition has to sign this contract" πŸ“


🌸 SYNOPSIS 🌸

the whole vibe in code form, bestie:

if <Catmandu::Fix::Condition instance>
        <pass_fixes>
else
        <fail_fixes>
end

like. it's an if/else. but make it Catmandu. iconic. πŸ‘‘


πŸŽ€ DESCRIPTION πŸŽ€

so here's the tea β˜• β€” every Catmandu::Fix condition out there needs to implement Catmandu::Fix::Condition. that's not optional, that's the rule, periodt.

this class is a subclass of Catmandu::Fix::Base, and what it brings to the group chat is two little lists:

  • a list of fixes that get executed when the conditional matches β€” that's your pass_fixes πŸŽ‰
  • and a conditional that needs to be executed when the conditional fails β€” that's your fail_fixes 😭
ngl, that second sentence is worded a liiittle cursed in the original, but the energy is: pass fixes fire on a match, fail fixes fire on a no-match. you got this πŸ’–

and plot twist β€” conditions can be used as inline fixes too! not just in the if/else block. look:

use Catmandu::Fix::Condition::exists as => 'has_field';

my $item = { foo => { bar => 1 } };

has_field($item, 'foo.bar');    # true
has_field($item, 'doz');        # false

see how foo.bar is true because it exists, and doz is false because... it does not? slay. that's the whole bit. 🧚


πŸ’– EXAMPLES πŸ’–

Catmandu core comes with these conditions, and honestly? the lineup ate. here's the full roster, no skips, no cuts:

  • all_equal
  • all_match
  • any_equal
  • any_match
  • exists
  • greater_than
  • in
  • is_array
  • is_false
  • is_null
  • is_number
  • is_object
  • is_string
  • is_true
  • less_than

sixteen of them. a whole squad. 🌈⭐


and that's the page!! πŸŽ€ this lil masterpiece comes to you from perl v5.40.1, dated 2026-01-24, and it's filed under that same Catman...dition(3pm) energy. go write a conditional, bestie, you're the main character now πŸ’…βœ¨

πŸ“¦ where this page comes from