From 779d5f96201a2fb693d6b83bb4ea5ff84de611e0 Mon Sep 17 00:00:00 2001 From: Vitali Peil Date: Thu, 1 Jun 2017 19:43:12 +0200 Subject: [PATCH] expand documentation, GH #251 --- lib/Catmandu/Fix/lookup.pm | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/Catmandu/Fix/lookup.pm b/lib/Catmandu/Fix/lookup.pm index af6a04857..0dfe1ff31 100644 --- a/lib/Catmandu/Fix/lookup.pm +++ b/lib/Catmandu/Fix/lookup.pm @@ -93,13 +93,30 @@ Catmandu::Fix::lookup - change the value of a HASH key or ARRAY index by looking up its value in a dictionary =head1 SYNOPSIS - - lookup(foo.bar, dictionary.csv) - lookup(foo.bar, dictionary.csv, sep_char: |) - # delete value if the lookup fails: - lookup(foo.bar, dictionary.csv, delete: 1) - # use a default value if the lookup fails: - lookup(foo.bar, dictionary.csv, default: 'default value') + # dictionary.csv + # id,planet + # 1,sun + # 2,earth + # 3,moon + + # values found in the dictionary.csv will be replaced + # {foo => {bar => 2}} + lookup(foo.bar, dictionary.csv) + # {foo => {bar => 'earth'}} + + # values not found will be kept + # {foo => {bar => 232}} + lookup(foo.bar, dictionary.csv) + # {foo => {bar => 232}} + + # in case you have a different seperator + lookup(foo.bar, dictionary.csv, sep_char: |) + + # delete value if the lookup fails: + lookup(foo.bar, dictionary.csv, delete: 1) + + # use a default value if the lookup fails: + lookup(foo.bar, dictionary.csv, default: 'default value') =head1 SEE ALSO