May 2017
Intermediate to advanced
416 pages
21h 33m
English
To read a file using an explicit file descriptor, use the function io.read:
file = io.open(filename) val = file:io.read("%d")
There is a function named io.lines that will take a filename as an argument and return an iterator to traverse each line of the filename. This function can help us process files in chunks divided into new lines:
for line in io.lines(filename) do if string.match(line, "<password>(.*)</password>") then … --Do something here endend
Read now
Unlock full access