Table of Contents
maparray
Table of Contents
Prototype: maparray(pattern, array)
Return type: slist
Description: Returns a list with each array element modified by a pattern.
The $(this.k) and $(this.v) variables expand to the key and value of the
array element, similar to the way this is available for maplist.
If a value in the array is an slist, you'll get one result for each
value (implicit looping).
The order of the array keys is not guaranteed. Use the sort
function if you need order in the resulting output.
Arguments:
Example:
body common control
{
bundlesequence => { "run" };
}
bundle agent run
{
vars:
"static[2]" string => "lookup 2";
"static[two]" string => "lookup two";
"static[big]" string => "lookup big";
"static[small]" string => "lookup small";
"todo[1]" string => "2";
"todo[one]" string => "two";
"todo[3999]" slist => { "big", "small" };
"map" slist => maparray("key='$(this.k)', static lookup = '$(static[$(this.v)])', value='$(this.v)'", "todo");
reports:
"mapped array: $(map)";
}
Output:
R: mapped array: key='3999', static lookup = 'lookup big', value='big'
R: mapped array: key='3999', static lookup = 'lookup small', value='small'
R: mapped array: key='one', static lookup = 'lookup two', value='two'
R: mapped array: key='1', static lookup = 'lookup 2', value='2'
