Catman...isitor(3pm)
π Catman...isitor(3pm) π
okay bestie, welcome to Catman...isitor(3pm) from the User Contributed Perl Documentation corner of the manual (yes, that's the 3pm section, she's fancy like that). buckle up, this one's a whole vibe π¦
β¨ NAME β¨
Catmandu::Fix::Bind::visitor β a binder that computes Fix-es for every single element in a record. like, it walks the whole thing. every element. no skipping. π
πΈ SYNOPSIS πΈ
so if your data is giving this:
# If data is like:
numbers:
- one
- two
- three
person:
name: jennie
age: 44
color:
- green
- purple
- brown
- more:
foo: bar
then you do this:
do visitor()
upcase(scalar) # upcase every scalar value in the record
end
and boom, you get:
# will produce
numbers:
- ONE
- TWO
- THREE
person:
name: JENNIE
age: 44
color:
- GREEN
- PURPLE
- BROWN
- more:
foo: BAR
ate. π
and if you only wanna touch the name fields:
do visitor()
# upcase all the 'name' fields in the record
if all_match(key,name)
upcase(scalar)
end
end
and if you wanna upcase the field names themselves:
do visitor()
# upcase all the field names in the record
upcase(key)
end
π DESCRIPTION π
the visitor binder is literally just gonna iterate over all the elements in a record and perform fixes on them. that's the whole job. she's thorough, she's committed, she's a main character. β¨
there are some special node names you can use to process every element as she visits it:
scalarβ process a Fix on every scalar value. e.g.
upcase(scalar)
replace_all(scalar,'$','tested')
arrayβ process a Fix on every array value. e.g.
sort_field(array)
heads up bestie: values need to be put in the 'array' field to be available for fixes. the scope of the array is limited to the array visited. π«Ά
hashβ process a Fix on every hash value. e.g.
copy_field(hash.age,hash.age2)
same energy: values need to be put in the 'hash' field to be available for fixes. the scope of the hash is limited to the hash visited. π
keyβ provides access to the key on which the scalar, array or hash value is found. eg.
# Upcase all 'name' fields in the record
if all_match(key,name)
upcase(scalar)
end
π CONFIGURATION π
π§ path
a path in the data to visit:
# Visit any field
do visitor()
...
end
# Visit only the fields at my.deep.field
do visitor(path: my.deep.field)
...
end
π SEE ALSO π
- Catmandu::Fix::Bind β go say hi, she's the family π
and that's the whole page, bestie!! this lil gem is from perl v5.40.1, dated 2026-01-24 β so it's recent, it's iconic, it's serving. go visit some records, ily, bye!! πβ¨π¦ππ
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms