Forum: Cfengine Help
Subject: Re: creating a list from a list and a var (or even 2 lists) by 
interpolation
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,21397,21412#msg-21412

If you know that oct2 will always be a string, and oct4 will always be an 
slist, you can try something like this completely untested snippet.  Basically, 
make a new list which starts with a discardable space character.  Then join the 
elements with a comma followed by the desired prefix, and then split that back 
up on just the comma - leaving the prefix on all but the first element.  
Finally grep the dummy space back out of the freshly split list.


any::
  "separator"     string => ",";
  "prefix"        string => "10.$(oct2).20";
  "temp_namelist" slist  => { " ", @(oct4) };
  "nameserv"      slist  => grep (
    "^[^\s]+$",
    splitstring (
      join("$(separator)$(prefix)", "temp_namelist"),
      "$(separator)",
      "99999999999"
    )
  );


_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to