... open INPUT_HANDLE .... or die ... while ( my $line = ) { chomp $line; process_line($line); last if eof(INPUT_HANDLE); } close(INPUT_HANDLE); ...