You can loop through hash tables as well by using $hfind(table,*,0,w) to get the number of entries in the hash. However, if you choose to store your data differently in the hash table, you can eliminate constantly looping through each entry. For example, if you wanted to know who has used a certain IP before, instead of using $nick as the ITEM and a list of addresses as the DATA, you could use a single address as the ITEM and a list of $nick's as the DATA.

12.34.56.78 = Bob,Sam,Mike,Betty
23.45.67.89 = Alan,Steve,Sally,Betty

Using that format if the address you were looking for was stored in %addr, you could find the list of names by using $hget(table,%addr).

If you are looking to be able to search for who has used a certain IP before, AND what IPs a certain person has used, I would recommend storing the info in the hash table BOTH ways. By using some kind of distinguishing prefix in the ITEM, you can store multiple sets of data in a single table. Example:

i-12.34.56.78 = Bob,Sam,Mike,Betty
i-23.45.67.89 = Sam,Steve,Sally,Betty
n-Bob = 12.34.56.78
n-Sam = 12.34.56.78,23.45.67.89
n-Mike = 12.34.56.78
n-Betty = 12.34.56.78
n-Steve = 23.45.67.89
n-Sally = 23.45.67.89


To find out who has used an IP, as above, you would now use $hget(table,$+(i-,%addr)). And to find out what IPs a certain nick has used, you would type $hget(table,$+(n-,%nick)).

It is much more efficient (in terms of speed) to do all the work twice when you are adding the data, rather than 10000 times each time you need to loop through every entry to find some data.

-genius_at_work