Catman...d::each(3pm)

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

πŸ’– Catmandu::Fix::Bind::each(3pm) β€” bestie edition πŸ’–

okay so listen. this is Catmandu::Fix::Bind::each, a Perl module, section 3pm of the manual. it's a binder that runs your fixes for every single (key, value) pair in a hash. she's giving very "one at a time, no skipping, we do everyone" energy and honestly? we're obsessed. ✨


🌸 NAME 🌸

Catmandu::Fix::Bind::each β€” a binder that executes fixes for every (key, value) pair in a hash πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

so first, imagine we made a hash. a little guy. a vibe:

# Create a hash:
# demo:
#   nl: 'Tuin der lusten'
#   en: 'The Garden of Earthly Delights'

# Create a list of all the titles, without the language tags.
do each(path: demo, var: t)
    copy_field(t.value, titles.$append)
end

# This will result in:
# demo:
#   nl: 'Tuin der lusten'
#   en: 'The Garden of Earthly Delights'
# titles:
#   - 'Tuin der lusten'
#   - 'The Garden of Earthly Delights'

# Upcase every key in the root hash
# foo: bar
# test: 1234
do each(path:., var: t)
   upcase(t.key)
end

# This will result in
# FOO: bar
# TEST: 1234

see how we just… collected all the titles with copy_field(t.value, titles.$append)? no language tags, no drama, just titles. and then the second one said "you know what, every key in the root hash is getting UPCASE" and the keys did not argue. periodt. πŸ‘‘


✨ DESCRIPTION ✨

the each binder iterates over a hash and hands you back a (key, value) pair β€” the inspiration for this bind is literally the Perl each function over at <http://perldoc.perl.org/functions/each.html>, so like, shoutout to the origin story 🫢 β€” and then it executes all the fixes for each pair. every. single. one. no cap.

the bind always returns a var.key and a var.value pair, and those are the ones you get to use inside your fixes. that's the whole deal bestie, that's the gift. 🎁


🌈 CONFIGURATION 🌈

πŸ¦‹ path

the path to a hash in the data. tell it where the hash lives and it'll go knock on the door. πŸšͺ

πŸ“ var

the temporary field that gets created in the root of the record, and it holds a key field and a value field β€” which contain, you guessed it, the key and the value of the iterated data. she's transparent, she's organized, she's an icon. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Pieter De Praetere, "pieter.de.praetere at helptux.be" πŸ’Œ


πŸ’œ SEE ALSO πŸ’œ

  • Catmandu::Fix::Bind::list
  • Catmandu::Fix::Bind

okay that's the whole page bestie, go forth and iterate πŸ’–βœ¨ no thoughts, just (key, value) pairs πŸ¦‹

perl v5.40.1 🌸 2026-01-24 β€” that's the source, the version and the date, mwah, tysm for reading, ily, bye!! πŸ’…πŸŽ€

πŸ“¦ where this page comes from