gawk: Arrays Summary

1 
1 8.7 Summary
1 ===========
1 
1    * Standard 'awk' provides one-dimensional associative arrays (arrays
1      indexed by string values).  All arrays are associative; numeric
1      indices are converted automatically to strings.
1 
1    * Array elements are referenced as 'ARRAY[INDX]'.  Referencing an
1      element creates it if it did not exist previously.
1 
1    * The proper way to see if an array has an element with a given index
1      is to use the 'in' operator: 'INDX in ARRAY'.
1 
1    * Use 'for (INDX in ARRAY) ...' to scan through all the individual
1      elements of an array.  In the body of the loop, INDX takes on the
1      value of each element's index in turn.
1 
1    * The order in which a 'for (INDX in ARRAY)' loop traverses an array
1      is undefined in POSIX 'awk' and varies among implementations.
1      'gawk' lets you control the order by assigning special predefined
1      values to 'PROCINFO["sorted_in"]'.
1 
1    * Use 'delete ARRAY[INDX]' to delete an individual element.  To
1      delete all of the elements in an array, use 'delete ARRAY'.  This
1      latter feature has been a common extension for many years and is
1      now standard, but may not be supported by all commercial versions
1      of 'awk'.
1 
1    * Standard 'awk' simulates multidimensional arrays by separating
1      subscript values with commas.  The values are concatenated into a
1      single string, separated by the value of 'SUBSEP'.  The fact that
1      such a subscript was created in this way is not retained; thus,
1      changing 'SUBSEP' may have unexpected consequences.  You can use
1      '(SUB1, SUB2, ...) in ARRAY' to see if such a multidimensional
1      subscript exists in ARRAY.
1 
1    * 'gawk' provides true arrays of arrays.  You use a separate set of
1      square brackets for each dimension in such an array:
1      'data[row][col]', for example.  Array elements may thus be either
1      scalar values (number or string) or other arrays.
1 
1    * Use the 'isarray()' built-in function to determine if an array
1      element is itself a subarray.
1