Skip to content

Commit 99976e7

Browse files
committed
Extend documentation for lookup() Fix function.
1 parent 5d756eb commit 99976e7

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,39 @@ join_field("<sourceField>", "<separator>")
553553

554554
Looks up matching values in a map and replaces the field value with this match. External files as well as internal maps can be used.
555555

556+
Parameters:
557+
558+
- `path` (required): Field path to look up.
559+
- `map` (optional): Name or path of the map in which to look up values.
560+
561+
Options:
562+
563+
- `__default`: Default value to use for unknown values. (Default: Old value)
564+
- `delete`: Whether to delete unknown values. (Default: `false`)
565+
556566
```perl
557-
lookup("<sourceField>", "<mapFile>", sep_char: ”,”)
558-
lookup("<sourceField>", "<mapName>")
559-
lookup("<sourceField>", "<mapName>", default: "NA")
567+
lookup("<sourceField>"[, <mapName>][, <options>...])
568+
```
569+
570+
E.g.:
571+
572+
```perl
573+
# local (unnamed) map
574+
lookup("path.to.field", key_1: "value_1", ...)
575+
576+
# internal (named) map
577+
put_map("internal-map", key_1: "value_1", ...)
578+
lookup("path.to.field", "internal-map")
579+
580+
# external file map (implicit)
581+
lookup("path.to.field", "path/to/file", sep_char: ";")
582+
583+
# external file map (explicit)
584+
put_filemap("path/to/file", "file-map", sep_char: ";")
585+
lookup("path.to.field", "file-map")
586+
587+
# with default value
588+
lookup("path.to.field", "map-name", __default: "NA")
560589
```
561590

562591
##### `prepend`

0 commit comments

Comments
 (0)