open (MYFILE, "< $filename") or die "Failed to open $filename: $!"; while () { # do something with $_ } close (MYFILE);