Sorry, it looks like I forgot .data on my IF. Putting .data on the end of the $hget in the IF statement should also work, just so you can see both ways of looping.

Code:
if ($hget(tablename,%count) >= 4) { do something }