A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.cfengine.com/latest/reference-functions-parserealarray.html below:

parserealarray - CFEngine 3.26 Docs

Prototype: parserealarray(array, input, comment, split, maxentries, maxbytes)

Return type: int

Description: Parses up to maxentries values from the first maxbytes bytes in string input and populates array. Returns the dimension.

This function mirrors the exact behavior of readrealarray(), but read data from a variable instead of a file. By making data readable from a variable, data driven policies can be kept inline.

The comment field is a multiline regular expression and will strip out unwanted patterns from the file being read, leaving unstripped characters to be split into fields. Using the empty string ("") indicates no comments.

Arguments:

Example:

code

bundle agent __main__
{
  vars:
      # Define data inline for convenience
      "table"
        string => "1.0:2.718
3:4.6692
5.0:6.82";


      "dim"
        int => parserealarray(
                               "items",
                               "$(table)",
                               "\s*#[^\n]*",
                               ":",
                               "1000",
                               "200000"
      );

      "keys" slist => sort(getindices("items"));

  reports:
      "$(keys) - $(items[$(keys)][1])";
}

Output:

code

R: 1.0 - 2.718
R: 3 - 4.6692
R: 5.0 - 6.82

History: Was introduced in version 3.1.5a1, Nova 2.1.0 (2011)

See also: parsestringarray(), parseintarray(), readstringarray(), readintarray(), readrealarray()


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4