[exim] Re: Reduce & inlist

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Jasen Betts
Data:  
Para: exim-users
Asunto: [exim] Re: Reduce & inlist
On 2024-02-28, Slavko via Exim-users <exim-users@???> wrote:
> Hi all,
>
> i found in ML archives recipe how to remove duplicates from list,
> i tried it in that form in file used -be input:
>
>     APPEND_ITEM = ${if def:value {$value,$item}{$item}}
>     INLIST = inlist{$item}{<,$value}
>
>     ${reduce{<, item1, item2, item1}\
>               {}\
>               {${if INLIST{$value}{APPEND_ITEM}}}}
>
> It works in 4.94, but doesn't work in 4.96 nor 4.97 (all stock debian
> packages). In the 4.96 & 97 it returns only "item1". From debug
> output and docs i understand, that when item is in list, the $value
> inside inlist contains matched item not that one from reduce, thus
> that matched item replaces result in reduces..
>
> I found some discussion about that in this thread
> https://lists.exim.org/lurker/message/20220922.124818.33ca8de7.es.html
> but i lost in it...
>
> Then i want to replace inlist by forany, but here is collision with $item
> values, thus i didn't try it. Finally i replaced inlist with match condition,
> which works, but i would to awoid regex if possible .
>
> Please, is here better way to remove duplicates than use regex
> in condition?


I see what you mean, "${if inlist" doesn't seem to work inside "${reduce"


I have in the past written complex loops using "${map" "${foreach" or "${filter"
and "${acl" but I'm not going to say that this is "better".

Embedded Perl is possibly a better approach, but it's been a decade
since I used that for anything.

--
Jasen.
🇺🇦 Слава Україні

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/