Catman...:lookup(3pm)
π NAME π
Catmandu::Fix::lookup β bestie, this is the fix that goes and swaps out the value of a HASH key or an ARRAY index by looking that value up in a dictionary. Like, you give it a value, it checks the dictionary, and boom π the value gets replaced. It's giving translator energy.
β¨ SYNOPSIS β¨
Okay so first, imagine your dictionary file. It's a little CSV, and honestly? iconic:
# dictionary.csv
# id,planet
# 1,sun
# 2,earth
# 3,moon
Now watch what happens. Any values found in dictionary.csv get replaced:
# values found in the dictionary.csv will be replaced
# {foo => {bar => 2}}
lookup(foo.bar, dictionary.csv)
# {foo => {bar => 'earth'}}
But if the value isn't in the dictionary? No worries, no chaos β values not found will be kept, exactly as they were:
# values not found will be kept
# {foo => {bar => 232}}
lookup(foo.bar, dictionary.csv)
# {foo => {bar => 232}}
And if your file uses a different separator, just tell it. Periodt:
# in case you have a different seperator
lookup(foo.bar, dictionary.csv, sep_char: |)
You can also delete the value entirely when the lookup fails:
# delete value if the lookup fails:
lookup(foo.bar, dictionary.csv, delete: 1)
Orrr you can be soft about it and set a fallback. A little default bestie π«Ά:
# use a default value if the lookup fails:
lookup(foo.bar, dictionary.csv, default: 'default value')
π SEE ALSO π
Catmandu::FixCatmandu::Fix::mapping
Okay that's the whole page, bestie! This one's from the User Contributed Perl Documentation, perl v5.40.1, dated 2026-01-24 π Go look up some values, you absolute legend. Mwah! πβ¨
π¦ 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