open my $file_handle, '<', 'filename.txt' or die $!; while( <$file_handle> ) { chomp; # do something with the line held in $_ } close $file_handle;