Catman...apping(3pm)

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

πŸ’– NAME πŸ’–

Catmandu::Fix::mapping β€” ok so bestie, this one moves several fields by a lookup table. that's the whole vibe. several fields, one lookup table, slay πŸ’…


✨ SYNOPSIS ✨

okay so here's literally the entire thing, no cap, read it slowly because it eats:

# field_mapping.csv
# AU,author
# TI,title
# PU,publisher
# Y,year

# fields found in the field_mapping.csv will be replaced
# {AU => "Einstein"}
mapping(field_mapping.csv)
# {author => "Einstein"}

# fields found in the field_mapping.csv with keep option will be copied
# {AU => "Einstein"}
mapping(field_mapping.csv, keep: 1)
# {AU => => "Einstein", author => "Einstein"}

# values not found will be kept
# {foo => {bar => 232}}
mapping(field_mapping.csv)
# {foo => {bar => 232}}

# in case you have a different seperator
mapping(field_mapping.csv, sep_char: |)

let's break it down so it actually makes sense 🧚

  • the lookup table lives in a file like field_mapping.csv, and each line is a <from>,<to> pair β€” so AU,author means "hey, AU? yeah that's author now."
  • fields that show up in the lookup table get replaced. you come in as {AU => "Einstein"}, you leave as {author => "Einstein"}. glow up ✨
  • add the keep option and instead of replacing, the field gets copied β€” so {AU => "Einstein"} becomes {AU => => "Einstein", author => "Einstein"}. both of them. icon behavior πŸ‘‘
  • values that aren't in the lookup table? kept, untouched, exactly as they were. {foo => {bar => 232}} in, {foo => {bar => 232}} out. we do not touch what we were not asked to touch 🫢
  • got a different seperator in your file? pass sep_char and set it, like mapping(field_mapping.csv, sep_char: |). iykyk πŸ”₯
ngl bestie, the doc calls it a "seperator" β€” that's how it's written, that's how i'm saying it, we don't correct the source material πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, fr fr:

  • Catmandu::Fix
  • Catmandu::Fix::lookup

and that's the whole page, bestie!! this one shipped in perl v5.40.1, dated 2026-01-24, from the User Contributed Perl Documentation collection πŸ’–βœ¨ mwah, go move some fields, you're gonna ate πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from