Catman...porter(3pm)

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

πŸ’– Catman...porter πŸ’–

okay bestie, buckle up, this is a Perl module page, section 3pm, and it's the one and only Catmandu::Fix::add_to_exporter ✨


πŸŽ€ NAME πŸŽ€

Catmandu::Fix::add_to_exporter β€” exports a record as a side effect πŸ’…

like, it doesn't just fix your data, it also yeets a copy of it out to a file while it's at it. multitasking queen behavior, no cap πŸ‘‘


🌸 SYNOPSIS 🌸

say it with me: add_to_exporter(PATH, EXPORTER, OPT...) πŸ¦‹

first up, the classic β€” exporting some data field values straight into a CSV file:

# Export the data field values to a CSV file
add_to_exporter(data,CSV, file:/tmp/test.txt, header: 1)

and if you want the whole entire record as JSON instead, she's got you:

# Export the complete record into a JSON file
add_to_exporter(data,JSON, file:/tmp/test.json, pretty:1)

and the general shape of it, fr fr β€” you hand over a PATH to an EXPORTER, plus one ore more OPT0s:

# In general, export a PATH to an EXPORTER with one ore more OPT0s
add_to_exporter(PATH,EXPORTER, OPT1:... , OPT2:... , OPT3:... , ...)

now here's the part that's lowkey iconic β€” you can use add_to_exporter to explode an ARRAY into many records πŸŽ† like, one thing goes in, a whole bunch of records come out. it's giving magic trick:

# Use the add_to_exporter to explode an ARRAY into many records
# E.g.
#   books:
#     - title: Graphic Design Rules
#       year: 2003
#     - title: Urban Sketching
#       year: 2013
#     - title: Findus flyttar ut
#       year: 2012
# And a fix file: exporter.fix
do with(path => books)
   add_to_exporter(.,JSON)
end
# You can get an output with 3 records using the command line function
catmandu convert JSON to Null --fix exporter.fix < book.json

so yeah β€” a fix file called exporter.fix, that little do with(path => books) block, and then ✨ 3 records ✨ pop out the other side using that command line function. ate and left no crumbs πŸ“


πŸ’œ SEE ALSO πŸ’œ

go be nosy, bestie, these two are the whole friend group:

  • Catmandu::Fix 🌈
  • Catmandu::Exporter 🧚

that's the whole page, and honestly? short and sweet, we love that for us 🫢 this was perl v5.40.1, dated 2026-01-24, and it lives in the User Contributed Perl Documentation section, manual page 3pm πŸ’– byeee, go export something gorgeous πŸ’…βœ¨

πŸ“¦ where this page comes from