Associative Arrays arrays introduction associative arrays introduction SystemTap also supports the use of associative arrays. While an ordinary variable represents a single value, associative arrays can represent a list of values. Simply put, an associative array is a collection of unique keys; each key in the array has a value associated with it. arrays introduction key pairs associative arrays introduction key pairs key pairs introduction arrays arrays introduction unique keys associative arrays introduction unique keys unique keys introduction arrays arrays introduction associated values associative arrays introduction associated values associated values introduction arrays arrays introduction index expression associative arrays introduction index expression index expression introduction arrays Since associative arrays are normally processed in multiple probes (as we will demonstrate later), they are declared as global variables in the SystemTap script. The syntax for manipulating arrays (i.e. accessing elements in an associative array) is similar to that of awk, and is as follows: arrays introduction syntax associative arrays introduction syntax syntax introduction arrays format introduction arrays array_name[index_expression] operation Here, the array_name is any arbitrary name the array uses. The index_expression is used to refer to a specific unique key (or set of unique keys) in the array, and the operation defines what to do with the index_expression. To illustrate, let us try to build an array named foo that specifies the ages of three people (i.e. the unique keys): tom, dick, and harry. To assign them the ages (i.e. associated values) of 23, 24, and 25 respectively, we'd use the following array statements: arrays introduction example associative arrays introduction example example introduction arrays Basic Array Statements foo["tom"] = 23 foo["dick"] = 24 foo["harry"] = 25 You can specify up to 5 index expressons in an array statement, each one delimited by a comma (,). This is useful if you wish to perform the same operation to a set of key pairs. For example, to increase the associated value of all the key pairs defined by , you can use the following statement: foo["tom","dick","harry"] ++ Important All associate arrays must be declared as global, regardless of whether the associate array is used in one or multiple probes.