Forum: CFEngine Help
Subject: Re: multidimensional array usage
Author: mark
Link to topic: https://cfengine.com/forum/read.php?3,23753,23765#msg-23765

This seems to be a quirk of the evaluation, if I add braces around the list 
function:


body common control
{
  bundlesequence => { "parse_array" };
}

bundle agent  parse_array
{
vars:
  "dim" int => readstringarray("servers", 
"/tmp/multidim_data.txt","\s*#[^\n]*",":",100,10000);

  "hostnames" slist => getindices("servers");

  "iparray[$(hostnames)]" string => "$(servers[$(hostnames)][1])";

  "ips" slist => { getvalues("iparray") };

reports:
  cfengine:: 
    "ips: $(ips)";
 
   "iparray: $(iparray[$(hostnames)])";

    "iparray2: $(servers[$(hostnames)][1])";


Then I get:

host$ ~/LapTop/cfengine/core/src/cf-agent -f ./test.cf
R: ips: 2.2.2.2
R: ips: 3.3.3.3
R: ips: 1.1.1.1
R: iparray: 1.1.1.1
R: iparray: 3.3.3.3
R: iparray: 2.2.2.2
R: iparray2: 1.1.1.1
R: iparray2: 3.3.3.3
R: iparray2: 2.2.2.2

You should report this as a bug.

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

Reply via email to