Skip to content

Commit

Permalink
Merge pull request #310 from vpeil/pr/issue_251
Browse files Browse the repository at this point in the history
expand documentation, GH #251
  • Loading branch information
nics authored Jun 2, 2017
2 parents 459d3ee + 779d5f9 commit e7acfa7
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions lib/Catmandu/Fix/lookup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7acfa7

Please sign in to comment.