Re: [exim] Usage of dnsdb primary mx

Top Page
Delete this message
Reply to this message
Author: John Burnham
Date:  
To: exim users
Subject: Re: [exim] Usage of dnsdb primary mx
>
> BTW - what does the reduce command do? I don't see reduce in the
> documentation index.
>

Towards the end of 11.5:

${reduce{<string1>}{<string2>}{<string3>}}

    This operation reduces a list to a single, scalar string. After expansion, <string1> is interpreted as a list, colon-separated by default, but the separator can be changed in the usual way. Then <string2> is expanded and assigned to the $value variable. After this, each item in the <string1> list is assigned to $item in turn, and <string3> is expanded for each of them. The result of that expansion is assigned to $value before the next iteration. When the end of the list is reached, the final value of $value is added to the expansion output. The reduce expansion item can be used in a number of ways. For example, to add up a list of numbers:


    ${reduce {<, 1,2,3}{0}{${eval:$value+$item}}}


    The result of that expansion would be 6. The maximum of a list of numbers can be found:


    ${reduce {3:0:9:4:6}{0}{${if >{$item}{$value}{$item}{$value}}}}


    At the end of a reduce expansion, the values of $item and $value are restored to what they were before. See also the filter and map expansion items.


John