in reply to foreach loop

Yes...but there's a cleaner way...
Open your file:
open(IN,"myfile.txt");

Create a while loop using the line operator on the filehandle you've just created:
while(<IN>){ each line of your file is iterated over... the contents of each line are stored in the variable $_ }