You can keep on struggling and writing ad hoc scripts, but what you should really do is transform your uniprot-ACN file into a real database (SQLite springs to mind) and then use the powers of DBI and SQL to do all your searching.
in reply to Extraction help.
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog: Imperial Deltronics