As others have said, you can just read the whole file in at once, and then be able to access all elements of the array. If you also want to remove newline characters to make the array easier to process, here is a handy one-liner. chomp(@myArray = <FILEHANDLE>);
Good luck!