ForNext
Only Do What Only You Can Do
116. read from file
VBScript
JScript
Perl
PHP
Python
Ruby
PowerShell
Scala
import scala.io.Source val src = Source.fromFile("/etc/passwd") for (line <- src.getLines) print(line)
F#
OCaml
let ic = open_in "/etc/passwd" in let line = input_line ic in print_endline line;;
Haskell
import IO readAndPrintLines h = do eof <- hIsEOF h if eof then return () else do line <- hGetLine h putStrLn line readAndPrintLines h main = do h <- openFile "/etc/passwd" ReadMode readAndPrintLines h