Catman...on::in(3pm)

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

πŸ’– NAME πŸ’–

Catmandu::Fix::Condition::in β€” bestie, this one only lets your fixes run when the data in one path is contained in another path. That's it, that's the whole vibe. ✨

It's a Condition fix, so it lives inside if / unless blocks and decides whether the stuff inside them actually happens. πŸ‘‘


🌸 SYNOPSIS 🌸

Okay so first up, comparing single values. If foo is 42 and bar is 42, then in(foo,bar) is true, and the fix inside runs:

#-------------------------------------------------------------------
# Compare single values
# foo => 42 , bar => 42 => in(foo,bar) -> true
if in(foo,bar)
   add_field(forty_two,ok)
end

Now when you're comparing a single value against an array, it's a whole different energy β€” you're testing whether that value is inside the array:

# When comparing single values to an array: test if the value is
# contained in the array

# foo => 1 , bar => [3,2,1]  => in(foo,bar) -> true
if in(foo,bar)
   add_field(test,ok)
end

# foo => 42 , bar => [1,2,3] => in(foo,bar) -> false
unless in(foo,bar)
   add_field(test,ok)
end

And then the examples go full pseudo-code, spelling out the true / false of a bunch of in() comparisons. Pseudo code, bestie, not real Perl β€” don't @ me:

# In the following examples we'll write in pseudo code the true/false
# values of some 'in()' comparissons

# scalars vs arrays - check if the value is in the array
foo: 42 , bar: [1,2,3]                   in(foo,bar) -> false
foo: 1  , bar: [1,2,3]                   in(foo,bar) -> true

# scalars vs hashes - check if the key is in the hash
foo: name , bar: { name => 'Patrick' }           in(foo,bar) -> true
foo: name , bar: { deep => {name => 'Nicolas'}}  in(foo,bar) -> false

# array vs array - check if the contents is equal
foo: [1,2] , bar: [1,2]                  in(foo,bar) -> true
foo: [1,2] , bar: [1,2,3]                in(foo,bar) -> false
foo: [1,2] , bar: [[1,2],3]              in(foo,bar) -> false

So real quick, the rules of the road, spelled out:

  • scalar vs array β€” checks if the value is in the array πŸ”
  • scalar vs hash β€” checks if the key is in the hash (top level only, no digging, we saw deep say no ma'am) πŸ•³οΈ
  • array vs array β€” checks if the contents are equal πŸ’…

😭 STATUS 😭

Heads up bestie β€” be aware this function is experimental in many perl versions. So like, it works, but it's giving "still cooking". Use with love and maybe a test suite. 🫢

πŸ¦‹ SEE ALSO πŸ¦‹

  • Catmandu::Fix

That's the whole page, babes. Written by the Perl documentation crew, shipped as perl v5.40.1, dated 2026-01-24. Go forth and conditionally fix things. πŸ’œβœ¨

πŸ“¦ where this page comes from