make use variables as an array index see examples
Example
$CatEmployees
Tom Jones44245/ A/ the543354
Mary Adams5346 One/4/ the28765
Sally Chang16547/ A/ Wu650000
Billy Black.16839/ at/ -336500$ awk' {name[x++]=$2}end{for (i=0; i<nr; i++) {print i,name[i]}} 'Employees
0Jones
1Adams
2Chang
3Black
Description: the subscript for the array name is a user-defined variable x. The operator + + indicates that this is a numeric variable. awk initializes x to 0, and adds 1 after each use of X (using the post-increment operator). The 2nd field of each record is assigned to the corresponding element in the array name. The end block uses a for loop to loop through the array, starting with subscript 0, and sequentially printing the values of the array elements. The subscript is just a key, so you don't have to start with 0. The subscript can begin with any value, either a number or a string.
Example:
$ awk' {id[nr]=$3}end{for (x=1; x<=nr; x + +) {print id[x]}} 'Employees
4424
5346
1654
1683
Description:the awk variable nr holds the record number of the current record. This example uses NR as subscript to assign the 3rd field of each record to the corresponding element in the array. Finally, the For loop loops through the array, printing out the values that are stored in the arrays.
Reference: http://www.linuxawk.com/jiaocheng/252.html
The subscript of the awk associative array