Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Must I use nested for loops to extract information from mult. arrays?

Status
Not open for further replies.

claud7

Programmer
Apr 27, 2003
1
AU
A while ago I wrote an awk program and I swear that the only way to extract information from multiple arrays with the same set of indices was to use nested for loops:

for (title in array1)
for (title2 in array2)
if (title=title2)
....

sort of thing..

Now, it seems to be working if I do:
for (title in array1)
print array1[title], array2[title]

Am I going nuts? Is it a possible result of a version change? Or did I just stuff up the first time I wrote something and that's why I ended up using nested loops instead??
 
The only way this works is if you are using
identical indices for each array.

This for instance:
array[1] = ".."
array[2] = ".."

array2[$(NF + 1)","x++] = $3
array2[$(NF + 1)","x++] = $9

Would never work using your example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top