I am not it will work for you but works for me
I change the array into hash
and use DBI to save it as a file
open it when I want and close it when I am done - save memory
your attention of looping is to find an element
so, use your value as the key for the hash
the search will be quick