Catman...isitor(3pm)

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

πŸ’– 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