Catmandu::Fix::Bind::each3pm
A binder that executes fixes for every (key, value) pair in a hash
Usage
# 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: 1234do each(path:., var: t)upcase(t.key)end# This will result in# FOO: bar# TEST: 1234
Overview
The each binder will iterate over a hash and return a (key, value) pair (see the Perl each <http://perldoc.perl.org/functions/each.html> function for the inspiration for this bind) and execute all fixes for each pair.
The bind always returns a "var.key" and "var.value" pair which can be used in the fixes.
Configuration
path
The path to a hash in the data.
var
The temporary field that will be created in the root of the record containing a "key" and "value" field containing the key and value of the iterated data.
Releases
4 releases since Debian 10 (Buster); the text changed 3 times.