You can populate a hash table and use $hfind