Catman..._match(3pm)

πŸ“¦
version 1.320 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’… Catman..._match(3pm) β€” no wait, bestie, this page is Catmandu::Fix::Condition::marc_any_match πŸŽ€

okay so this is a Perl manual page from the User Contributed Perl Documentation, filed under Catman..._match(3pm) (yes the name is doing its own thing, we don't question the filing system πŸ’€). It's a Catmandu Fix condition, and it is so useful, like genuinely.


✨ NAME ✨

Catmandu::Fix::Condition::marc_any_match β€” test if a MARC (sub)field matches a value. that's it, that's the job, and it does it flawlessly 🫢


🌸 SYNOPSIS 🌸

the whole vibe, verbatim:

# marc_any_match(MARC_PATH,REGEX)

# Match when 245 contains the value "My funny title"
if marc_any_match('245','My funny title')
     add_field('my.funny.title','true')
end

# Match when 245a contains the value "My funny title"
if marc_any_match('245a','My funny title')
     add_field('my.funny.title','true')
end

# Match when at least one 650 field contains digits
if marc_any_match('650','[0-9]')
  add_field('has_digits','true')
end

see how it's just if + the condition + the fixes you want + end? iconic structure, no notes πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: the enclosing fixes only get evaluated if the MARC (sub)field matches a regular expression. no match, no fixes, the block just sits there respectfully πŸ™ˆ

and here's the part that matters β€” when the MARC field is a repeated field, then at least one of those MARC fields should match the regular expression. one little match is enough to let the whole thing through. slay ⭐


πŸ‘‘ METHODS πŸ‘‘

marc_any_match(MARC_PATH, REGEX)

evaluates to true when at least one MARC_PATH value matches the REGEX, and false otherwise. that's the whole personality, and honestly? it's enough πŸ’…


🌈 SEE ALSO 🌈

  • Catmandu::Fix::Condition::marc_all_match β€” the sibling, the counterpart, the "all of them have to match" one. go say hi πŸ‘‹

lowkey a tiny condition with main character energy. use it whenever you need "any of these MARC things match this pattern" and you'll never look back. periodt πŸ’œ

perl v5.38.2 🌸 2024-08-03 πŸŽ€ Catman..._match(3pm) β€” that's the version, the date, and the name it's filed under, and that's a wrap bestie, go write some fire fixes πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from